Created
August 26, 2012 12:25
-
-
Save gfixler/3478442 to your computer and use it in GitHub Desktop.
Simple SVN blame temporal grayscale colorization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
SVN blame temporal colorizer | |
Pipe shell output of `svn blame` through this. | |
Creates a grayscale heatmap of recentness of line changes. | |
Normalizes range of revisions over 20 shades of gray. | |
Usage: | |
# colorize file | |
svn blame file | python blamecol.py | |
# view entire file more easily | |
svn blame file | python blamecol.py | more | |
# colorize part of file | |
svn blame file | tail -n 50 | python blamecol.py | |
''' | |
import sys | |
lines = sys.stdin.readlines() | |
low = None | |
high = None | |
for line in lines: | |
rev = float(line.split()[0]) | |
if low == None or rev < low: low = rev | |
if high == None or rev > high: high = rev | |
for line in lines: | |
rev = float(line.split()[0]) | |
color = int(round((rev - low) / (high - low) * 20 + 235)) | |
print '\x1b[38;5;%dm%s\x1b[0m' % (color, line), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment