Skip to content

Instantly share code, notes, and snippets.

@tantalor tantalor/bliff.pl
Created Mar 12, 2011

Embed
What would you like to do?
Combines svn blame and diff.
#!/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
You can’t perform that action at this time.