2005-07-01 10:22:27 +04:00
|
|
|
#!/bin/sh
|
2005-05-29 01:31:49 +04:00
|
|
|
#
|
|
|
|
# This is an example of using HGEDITOR to automate the signing of
|
|
|
|
# commits and so on.
|
|
|
|
|
2005-06-14 11:49:52 +04:00
|
|
|
T1=""; T2=""
|
|
|
|
cleanup_exit() {
|
|
|
|
rm -f "$T1" "$T2"
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
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-06-14 11:49:52 +04:00
|
|
|
case "${EDITOR:=vi}" in
|
|
|
|
emacs)
|
|
|
|
EDITOR="$EDITOR -nw"
|
|
|
|
;;
|
|
|
|
gvim|vim)
|
|
|
|
EDITOR="$EDITOR -f -o"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if grep -q "^HG: merge resolve" "$1" ; then
|
2005-05-29 01:31:49 +04:00
|
|
|
# we don't sign merges
|
2005-06-14 11:49:52 +04:00
|
|
|
exec $EDITOR "$1"
|
2005-05-29 01:31:49 +04:00
|
|
|
else
|
2005-07-11 04:00:49 +04:00
|
|
|
# Remove temporary files even if we get interrupted
|
|
|
|
trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
|
2005-06-14 11:49:52 +04:00
|
|
|
T1=`mktemp`; T2=`mktemp`
|
2005-07-12 09:54:37 +04:00
|
|
|
MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
|
2005-06-14 11:49:52 +04:00
|
|
|
|
2005-07-12 09:54:37 +04:00
|
|
|
echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
|
|
|
|
grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
|
2005-06-26 14:33:16 +04:00
|
|
|
(
|
|
|
|
cd "`hg root`"
|
|
|
|
grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
|
|
|
|
hg diff "$changed" >> "$T2"
|
|
|
|
done
|
|
|
|
)
|
2005-06-14 11:49:52 +04:00
|
|
|
|
|
|
|
CHECKSUM=`md5sum "$T1"`
|
|
|
|
$EDITOR "$T1" "$T2" || cleanup_exit $?
|
2005-07-12 09:51:06 +04:00
|
|
|
echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 13
|
2005-06-14 11:49:52 +04:00
|
|
|
{
|
2005-07-11 04:00:24 +04:00
|
|
|
head -n 1 "$T1"
|
2005-06-14 11:49:52 +04:00
|
|
|
echo
|
2005-07-11 04:00:56 +04:00
|
|
|
grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign
|
2005-06-14 11:49:52 +04:00
|
|
|
} > "$T2" && mv "$T2" "$1"
|
|
|
|
cleanup_exit $?
|
2005-05-29 01:31:49 +04:00
|
|
|
fi
|
2005-06-14 11:49:52 +04:00
|
|
|
|