Skip to content

Instantly share code, notes, and snippets.

@keturn
Created October 13, 2011 19:13
Show Gist options
  • Save keturn/1285207 to your computer and use it in GitHub Desktop.
Save keturn/1285207 to your computer and use it in GitHub Desktop.
hg repository diff
#!/bin/bash
# diff working copy of two mercurial repositories.
# Only include tracked files.
# Adapted from http://mercurial.selenic.com/wiki/GenerateDiffBetweenRepositories
if [ $# -eq 1 ] ; then
SRC=$PWD
DEST=$1
elif [ $# -eq 2 ] ; then
SRC=$1
DEST=$2
else
echo "Wrong number of arguments. Expected"
echo "$0 [source] destination"
exit 1
fi
echo diff from
hg --cwd $SRC tip
echo
echo diff to
hg --cwd $DEST tip
# Get all the files tracked in either repository.
FILES=$((hg --cwd $SRC status -nmarc ; hg --cwd $DEST status -nmarc) | sort | uniq )
for FILE in $FILES; do
if [ -f $SRC/$FILE -o -f $DEST/$FILE ] ; then
diff -Nu $SRC/$FILE $DEST/$FILE
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment