Saturday, May 13, 2006

subversion diff wrapper


I am working on some projects that use subversion as their source control tool.  I don't mind the command line tool to check things in and out, but I don't like using diff as my coparison tool.  Subversion does allow an external diff tool to be used, but the way that the tool is called is not like the standard "command <file1> <file2>


So I created a wrapper script, based upon this script, that will allow you to use any diff program when you do "svn diff"





#!/usr/bin/env bash
# if the SVN_DIFF environment variable is not set, fall back to the diff
# program specified here
DIFF_PROG=mgdiff
TMPFILE=""
# remove tmp-file and leave program
# look for diff program
DIFF="unknown"
# first try $SVN_DIFF
if [ ! -z $SVN_DIFF ]
then
DIFF=`which $SVN_DIFF 2> /dev/null || echo unknown`
SEARCHED=$SVN_DIFF
fi
# if we found the prog, everything's fine
# otherwise look for prog specified above...
if [ $DIFF == "unknown" ]
then
DIFF=`which $DIFF_PROG 2> /dev/null || echo unknown`
if [ ! ${SEARCHED}x = x ]; then SEARCHED="$SEARCHED or "; fi
SEARCHED="$SEARCHED$DIFF_PROG"
# if we still coudn't find a diff, exit
if [ $DIFF == "unknown" ]
then
echo "Couldn't find $SEARCHED, is it installed and in \$PATH?"
cleanup 2
fi
fi
echo "using diff: $DIFF"
$DIFF $6 $7



On my mac, I am now using twdiff, which is the command line diff program that comes with TextWrangler


Technorati Tags: