% svn diff --diff-cmd colordiff -x -w files |\
less -RS
(I like to pass -w to the diff-er to ignore whitespace changes). Piping through less in rawmode (-r/-R) interprets the colour escape-sequences correctly.
Thanks to commandlinefu for the idea.
Thanks for the great tip Mat.
ReplyDeleteI was wondering whether this could get put into ~/.subversion/config somehow so that you just had to do a
svn diff file
command. From what I can see the labels have to be parsed to put then in quotes.
So I created a little perl script (see below) called mydiff.pl which I put in my binary area "~/bin", and edited my ~/.subversion/config so that it contains the line:
diff-cmd = /bin/mydiff.pl
Anyway here is the perl script:
#!/usr/bin/perl
my @args = ();
my $L = 0;
my $carg='';
while (<@ARGV>) {
if ($L==1) {
$carg = $_;
$carg ="\"".$carg;
$L++;
next;
} elsif ($L>1) {
$carg = $carg." ".$_;
if (m/\)$/) {
$carg = $carg."\" ";
$L = 0;
} else {
next;
}
} else {
$carg = $_;
if (m/^\-L/) {$L++;}
}
push @args,$carg;
}
system ("/usr/bin/colordiff -x -w -B @args");