Monday, November 12, 2012

Using TkDiff with Subversion on OSX

Step 1: Download and install TkDiff

Download this from SourceForge, unpack the disk image, and drag the tkdiff application to your Applications directory.

Step 2: Set up an alias to run TkDiff from the command line

In bash on my machine, I added the following to my PATH in my ~/.bash_profile so I could run it via the command line.
PATH="/Applications/TkDiff.app/Contents/MacOS/:${PATH}"

Step 3: Tell Subversion to use TkDiff instead of the default

You'll need an adapter script so Subversion can call TkDiff correctly.
#!/bin/sh
# Configure your favorite diff program here.
DIFF="tkdiff" 
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7} 
# Call the diff command (change the following line to make sense for
# your merge program).
$DIFF $LEFT $RIGHT
Then add the following to ~/.subversion/config to default to this diff method.
diff-cmd = /Users/tgnourse/scripts/tkdiff-svn-wrapper.sh

Step 4: Success!

Now you can diff all your edits like so:
svn diff
In addition, TkDiff has built in subversion support so you can also diff single files like so:
tkdiff your/file.ext