RubyGreenBlue

External diff with Subversion using BBEdit

Posted by keith over 2 years ago

BBEdit has a great Find Differences function. You get a list of description of differences that you can click on to see the two affected files. You can also do things like apply the difference to either the new or the old file.

Subversion's differences output is of course command-line only, but subversion does support using external diff tools.

Enter bbdiff from John Gruber.

bbdiff is a command line interface to BBEdit's Find Differences command.

Download bbdiff from John Gruber's site, and follow his install instructions (very easy, copy it to where you want it and chmod it to be executable)

You will need to setup subversion to actually use an external diff command. To do this we will need to write a quick interface between the svn diff command and the bbdiff command as the argument lists do not match.

The arguments we want from the svn diff command are $6 (old file) and $7 (new file).

The bbdiff usage states:

Usage: /usr/local/bin/bbdiff [-b -i -s] oldfile newfile
-b keep BBEdit in the background
-i case insensitive comparison
-s ignore leading and trailing whitespace on lines

So we see that we need to pass in params $6 and $7 from the svn diff command in the order that they appear. Write a script that calls bbdiff with those params. Mine is called svndiff2bbdiff:

/usr/local/bin/bbdiff $6 $7

Make sure you chmod your svndiff2bbdiff file to be executable (chmod +x svndiff2bbdiff).

In your ~/.subversion/config file, search for the [helpers] section and create a line like:

diff-cmd = /usr/local/bin/svndiff2bbdiff

assuming your svndiff2bbdiff is in /usr/local/bin/

Test it out: svn diff -r PREV <file_name>.