Created
March 12, 2011 03:07
-
-
Save tantalor/866994 to your computer and use it in GitHub Desktop.
Combines svn blame and diff.
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/perl | |
use strict; | |
use List::Util 'max'; | |
my ($from, $to) = @ARGV | |
or die "usage: $0 OLD-URL[\@OLDREV] NEW-URL[\@NEWREV]\n"; | |
my @diff = `svn diff $from $to` or die; | |
my @blame = map {/^\s*(\d+)/} `svn blame $to` or die; | |
my $pad = max map {length} @blame; | |
for (my $diff_ln = 0; $diff_ln < @diff; $diff_ln++) { | |
if (my ($to_ln) = $diff[$diff_ln] =~ /@@ -\d+,\d+ \+(\d+),\d+ @@/) { | |
$diff_ln++; | |
for (my $off_ln = 0; $diff[$diff_ln] && $diff[$diff_ln+1] !~ /@@/; $diff_ln++) { | |
if ($diff[$diff_ln] =~ /^\+(.*)$/) { | |
printf "%${pad}d: %s\n", $blame[$to_ln+$off_ln], $1; | |
} | |
$off_ln++ unless $diff[$diff_ln] =~ /^-/; | |
} | |
print "\n" if $diff_ln < @diff; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment