3 # This is an example of using HGEDITOR to create of diff to review the
4 # changes while commiting.
6 # If you want to pass your favourite editor some other parameters
7 # only for Mercurial, modify this:
16 EDITOR="$EDITOR -f -o"
26 # Remove temporary files even if we get interrupted
27 trap "cleanup_exit" 0 # normal exit
28 trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
30 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
31 (umask 077 && mkdir "$HGTMP") || {
32 echo "Could not create temporary directory! Exiting." 1>&2
37 grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
38 "$HG" diff "$changed" >> "$HGTMP/diff"
42 cat "$1" > "$HGTMP/msg"
44 MD5=$(which md5sum 2>/dev/null) || \
45 MD5=$(which md5 2>/dev/null)
46 [ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/msg"`
47 if [ -s "$HGTMP/diff" ]; then
48 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
50 $EDITOR "$HGTMP/msg" || exit $?
52 [ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)