##// END OF EJS Templates
Turn off signing with hgeditor by default...
Matt Mackall -
r684:4ccf3de5 0.6b default
parent child Browse files
Show More
@@ -1,51 +1,59 b''
1 #!/bin/sh
1 #!/bin/sh
2 #
2 #
3 # This is an example of using HGEDITOR to automate the signing of
3 # This is an example of using HGEDITOR to automate the signing of
4 # commits and so on.
4 # commits and so on.
5
5
6 # change this to one to turn on GPG support
7 SIGN=0
8
6 T1=""; T2=""
9 T1=""; T2=""
7 cleanup_exit() {
10 cleanup_exit() {
8 rm -f "$T1" "$T2"
11 rm -f "$T1" "$T2"
9 exit $1
12 exit $1
10 }
13 }
11
14
12 # If you want to pass your favourite editor some other parameters
15 # If you want to pass your favourite editor some other parameters
13 # only for Mercurial, modify this:
16 # only for Mercurial, modify this:
14 case "${EDITOR:=vi}" in
17 case "${EDITOR:=vi}" in
15 emacs)
18 emacs)
16 EDITOR="$EDITOR -nw"
19 EDITOR="$EDITOR -nw"
17 ;;
20 ;;
18 gvim|vim)
21 gvim|vim)
19 EDITOR="$EDITOR -f -o"
22 EDITOR="$EDITOR -f -o"
20 ;;
23 ;;
21 esac
24 esac
22
25
23 if grep -q "^HG: merge resolve" "$1" ; then
26 if grep -q "^HG: merge resolve" "$1" ; then
24 # we don't sign merges
27 # we don't sign merges
25 exec $EDITOR "$1"
28 exec $EDITOR "$1"
26 else
29 else
27 # Remove temporary files even if we get interrupted
30 # Remove temporary files even if we get interrupted
28 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
31 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
29 T1=`mktemp`; T2=`mktemp`
32 T1=`mktemp`; T2=`mktemp`
30 MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
33 MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-`
31
34
32 echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
35 echo -e "\n\nmanifest hash: $MANIFEST" >> "$T1"
33 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
36 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1"
34 (
37 (
35 cd "`hg root`"
38 cd "`hg root`"
36 grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
39 grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
37 hg diff "$changed" >> "$T2"
40 hg diff "$changed" >> "$T2"
38 done
41 done
39 )
42 )
40
43
41 CHECKSUM=`md5sum "$T1"`
44 CHECKSUM=`md5sum "$T1"`
42 $EDITOR "$T1" "$T2" || cleanup_exit $?
45 $EDITOR "$T1" "$T2" || cleanup_exit $?
43 echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 13
46
44 {
47 if [ "$SIGN" == "1" ] ; then
45 head -n 1 "$T1"
48 echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 13
46 echo
49 {
47 grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign
50 head -n 1 "$T1"
48 } > "$T2" && mv "$T2" "$1"
51 echo
52 grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign
53 } > "$T2" && mv "$T2" "$1"
54 else
55 mv "$T1" "$1"
56 fi
49 cleanup_exit $?
57 cleanup_exit $?
50 fi
58 fi
51
59
General Comments 0
You need to be logged in to leave comments. Login now