Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 80 lines (69 sloc) 1.49 KB
#!/bin/sh
#
# Wrapper script to use FileMerge as a diff-cmd in Subversion
#
FM="$(which filemerge)"
FMDIFF="$(basename $0)"
GN="/usr/local/bin/growlnotify"
# Resolve symlinks leading to FileMerge
while [ -L "$FM" ]; do
FM_DIR="$(dirname "$FM")"
FM="$(readlink "$FM")"
[[ $FM == /* ]] || FM="$FM_DIR/$FM"
done
while [ $# != 0 ]; do
case $1 in
-u)
unified=1
;;
-L)
shift
if [ -z "$leftlabel" ]; then
leftlabel=$1
elif [ -z "$rightlabel" ]; then
rightlabel=$1
else
echo "Too many labels" 1>&2
exit 2
fi
;;
-*)
echo "Unknown option: $1" 1>&2
exit 2
;;
*)
if [ -z "$leftfile" ]; then
leftfile=$1
elif [ -z "$rightfile" ]; then
rightfile=$1
else
echo "Too many files to diff" 1>&2
exit 2
fi
esac
shift
done
if [ -z "$leftfile" ] || [ -z "$rightfile" ]; then
echo "Usage: $FMDIFF [options] leftfile rightfile" 1>&2
exit 2
fi
if svn info "$rightfile" &>/dev/null; then
mergefile="$rightfile"
fi
function labels {
[ -n "$leftlabel" ] && echo Left: $leftlabel
[ -n "$rightlabel" ] && echo Right: $rightlabel
[ -n "$mergefile" ] && echo Merge: $mergefile
}
echo Starting FileMerge... 1>&2
labels 1>&2
if [ -x "$GN" ]; then
labels | "$GN" -a FileMerge -n "$FMDIFF" "Starting FileMerge"
fi
if [ -n "$mergefile" ]; then
[[ "$mergefile" == */* ]] || mergefile="./$mergefile"
exec "$FM" -left "$leftfile" -right "$rightfile" \
-ancestor "$leftfile" -merge "$mergefile"
else
exec "$FM" -left "$leftfile" -right "$rightfile"
fi