annotate hgeditor @ 822:b678e6d4f92d

Attempt to yield names in sorted order when walking. This is an improvement in behaviour, but the walk and changes code still has some flaws that make sorted name presentation difficult: - changes returns tuples of names, instead of a sorted list of (name, status) pairs. - walk yields deleted names after all others.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 31 Jul 2005 18:03:46 -0800
parents 0902ffece4b4
children 232d0616a80a 1fe3b14c7044 9c918287d10b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
544
3d4d5f2aba9a Remove bashisms and use /bin/sh instead of /bin/bash.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 484
diff changeset
1 #!/bin/sh
186
9a2075c0b9b8 Add $HGEDITOR hook and example script
mpm@selenic.com
parents:
diff changeset
2 #
9a2075c0b9b8 Add $HGEDITOR hook and example script
mpm@selenic.com
parents:
diff changeset
3 # This is an example of using HGEDITOR to automate the signing of
9a2075c0b9b8 Add $HGEDITOR hook and example script
mpm@selenic.com
parents:
diff changeset
4 # commits and so on.
9a2075c0b9b8 Add $HGEDITOR hook and example script
mpm@selenic.com
parents:
diff changeset
5
684
4ccf3de52989 Turn off signing with hgeditor by default
Matt Mackall <mpm@selenic.com>
parents: 683
diff changeset
6 # change this to one to turn on GPG support
4ccf3de52989 Turn off signing with hgeditor by default
Matt Mackall <mpm@selenic.com>
parents: 683
diff changeset
7 SIGN=0
4ccf3de52989 Turn off signing with hgeditor by default
Matt Mackall <mpm@selenic.com>
parents: 683
diff changeset
8
666
0100a43788ca hgeditor: Remove EMAIL default for HGUSER, comment editor selection
Radoslaw "AstralStorm" Szkodzinski <astralstorm@gorzow.mm.pl>
parents: 665
diff changeset
9 # If you want to pass your favourite editor some other parameters
0100a43788ca hgeditor: Remove EMAIL default for HGUSER, comment editor selection
Radoslaw "AstralStorm" Szkodzinski <astralstorm@gorzow.mm.pl>
parents: 665
diff changeset
10 # only for Mercurial, modify this:
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
11 case "${EDITOR}" in
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
12 "")
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
13 EDITOR="vi"
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
14 ;;
348
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
15 emacs)
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
16 EDITOR="$EDITOR -nw"
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
17 ;;
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
18 gvim|vim)
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
19 EDITOR="$EDITOR -f -o"
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
20 ;;
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
21 esac
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
22
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
23
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
24 HGTMP=""
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
25 cleanup_exit() {
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
26 rm -rf "$HGTMP"
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
27 exit $1
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
28 }
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
29
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
30 # Remove temporary files even if we get interrupted
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
31 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
32
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
33 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
34 (umask 077 && mkdir "$HGTMP") || {
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
35 echo "Could not create temporary directory! Exiting." 1>&2
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
36 exit 1
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
37 }
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
38
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
39 (
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
40 cd "`hg root`"
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
41 grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
42 hg diff "$changed" >> "$HGTMP/diff"
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
43 done
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
44 )
348
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
45
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
46 echo > "$HGTMP/msg"
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
47 if [ "$SIGN" == "1" ]; then
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
48 MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
49 echo -e "\nmanifest hash: $MANIFEST" >> "$HGTMP/msg"
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
50 fi
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
51 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg"
684
4ccf3de52989 Turn off signing with hgeditor by default
Matt Mackall <mpm@selenic.com>
parents: 683
diff changeset
52
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
53 CHECKSUM=`md5sum "$HGTMP/msg"`
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
54 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || cleanup_exit $?
769
0c033ef053ab hgeditor: hide checksum mismatch message from md5sum
mpm@selenic.com
parents: 754
diff changeset
55 echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && cleanup_exit 13
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
56
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
57 if [ "$SIGN" == "1" ]; then
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
58 {
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
59 head -n 1 "$HGTMP/msg"
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
60 echo
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
61 grep -v "^HG:" "$HGTMP/msg" | gpg -t -a -u "${HGUSER}" --clearsign
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
62 } > "$HGTMP/msg.gpg" && mv "$HGTMP/msg.gpg" "$1"
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
63 else
796
33a272b79e54 Replaced mktemp and usage of ${par:=word}.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 769
diff changeset
64 mv "$HGTMP/msg" "$1"
186
9a2075c0b9b8 Add $HGEDITOR hook and example script
mpm@selenic.com
parents:
diff changeset
65 fi
348
442eb02cf870 Improved hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 280
diff changeset
66
754
3e73bf876f17 Fixes and cleanups to hgeditor:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 684
diff changeset
67 cleanup_exit $?