2005-07-01 10:22:27 +04:00
|
|
|
#!/bin/sh
|
2005-05-29 01:31:49 +04:00
|
|
|
#
|
2005-12-27 22:12:53 +03:00
|
|
|
# This is an example of using HGEDITOR to create of diff to review the
|
2015-10-17 01:58:46 +03:00
|
|
|
# changes while committing.
|
2005-07-12 09:56:29 +04:00
|
|
|
|
2005-07-11 04:00:56 +04:00
|
|
|
# If you want to pass your favourite editor some other parameters
|
|
|
|
# only for Mercurial, modify this:
|
2005-07-29 17:52:45 +04:00
|
|
|
case "${EDITOR}" in
|
|
|
|
"")
|
|
|
|
EDITOR="vi"
|
|
|
|
;;
|
2005-06-14 11:49:52 +04:00
|
|
|
emacs)
|
|
|
|
EDITOR="$EDITOR -nw"
|
|
|
|
;;
|
|
|
|
gvim|vim)
|
|
|
|
EDITOR="$EDITOR -f -o"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2005-07-29 17:52:45 +04:00
|
|
|
|
|
|
|
HGTMP=""
|
|
|
|
cleanup_exit() {
|
|
|
|
rm -rf "$HGTMP"
|
|
|
|
}
|
|
|
|
|
2005-07-22 10:30:52 +04:00
|
|
|
# Remove temporary files even if we get interrupted
|
2005-08-04 20:43:05 +04:00
|
|
|
trap "cleanup_exit" 0 # normal exit
|
2010-05-11 14:06:30 +04:00
|
|
|
trap "exit 255" HUP INT QUIT ABRT TERM
|
2005-07-29 17:52:45 +04:00
|
|
|
|
2010-05-19 20:06:35 +04:00
|
|
|
HGTMP=$(mktemp -d ${TMPDIR-/tmp}/hgeditor.XXXXXX)
|
|
|
|
[ x$HGTMP != x -a -d $HGTMP ] || {
|
|
|
|
echo "Could not create temporary directory! Exiting." 1>&2
|
|
|
|
exit 1
|
2005-07-29 17:52:45 +04:00
|
|
|
}
|
|
|
|
|
2005-07-22 10:30:52 +04:00
|
|
|
(
|
|
|
|
grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
|
2007-06-23 22:22:17 +04:00
|
|
|
"$HG" diff "$changed" >> "$HGTMP/diff"
|
2005-07-22 10:30:52 +04:00
|
|
|
done
|
|
|
|
)
|
|
|
|
|
2005-12-27 22:12:53 +03:00
|
|
|
cat "$1" > "$HGTMP/msg"
|
2005-07-22 10:30:52 +04:00
|
|
|
|
2006-07-28 22:46:19 +04:00
|
|
|
MD5=$(which md5sum 2>/dev/null) || \
|
2007-06-21 11:25:49 +04:00
|
|
|
MD5=$(which md5 2>/dev/null)
|
2006-07-28 22:46:19 +04:00
|
|
|
[ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/msg"`
|
2005-08-22 21:56:52 +04:00
|
|
|
if [ -s "$HGTMP/diff" ]; then
|
|
|
|
$EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
|
|
|
|
else
|
|
|
|
$EDITOR "$HGTMP/msg" || exit $?
|
|
|
|
fi
|
2006-07-28 22:46:19 +04:00
|
|
|
[ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)
|
2005-07-22 10:30:52 +04:00
|
|
|
|
2005-12-27 22:12:53 +03:00
|
|
|
mv "$HGTMP/msg" "$1"
|
2005-06-14 11:49:52 +04:00
|
|
|
|
2005-08-04 20:43:05 +04:00
|
|
|
exit $?
|