Show More
@@ -1,51 +1,53 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 | T1=""; T2="" |
|
6 | T1=""; T2="" | |
7 | cleanup_exit() { |
|
7 | cleanup_exit() { | |
8 | rm -f "$T1" "$T2" |
|
8 | rm -f "$T1" "$T2" | |
9 | exit $1 |
|
9 | exit $1 | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
|
12 | # If you want to pass your favourite editor some other parameters | |||
|
13 | # only for Mercurial, modify this: | |||
12 | case "${EDITOR:=vi}" in |
|
14 | case "${EDITOR:=vi}" in | |
13 | emacs) |
|
15 | emacs) | |
14 | EDITOR="$EDITOR -nw" |
|
16 | EDITOR="$EDITOR -nw" | |
15 | ;; |
|
17 | ;; | |
16 | gvim|vim) |
|
18 | gvim|vim) | |
17 | EDITOR="$EDITOR -f -o" |
|
19 | EDITOR="$EDITOR -f -o" | |
18 | ;; |
|
20 | ;; | |
19 | esac |
|
21 | esac | |
20 |
|
22 | |||
21 | if grep -q "^HG: merge resolve" "$1" ; then |
|
23 | if grep -q "^HG: merge resolve" "$1" ; then | |
22 | # we don't sign merges |
|
24 | # we don't sign merges | |
23 | exec $EDITOR "$1" |
|
25 | exec $EDITOR "$1" | |
24 | else |
|
26 | else | |
25 | # Remove temporary files even if we get interrupted |
|
27 | # Remove temporary files even if we get interrupted | |
26 | trap "cleanup_exit 255" TERM KILL INT QUIT ABRT |
|
28 | trap "cleanup_exit 255" TERM KILL INT QUIT ABRT | |
27 | T1=`mktemp`; T2=`mktemp` |
|
29 | T1=`mktemp`; T2=`mktemp` | |
28 |
|
30 | |||
29 | # Add manifest hash in order to sign whole repository state. |
|
31 | # Add manifest hash in order to sign whole repository state. | |
30 | # Remove HG: prefix, as we want that to be stored. |
|
32 | # Remove HG: prefix, as we want that to be stored. | |
31 | grep '^HG: manifest hash' "$1" | cut -b 5- >> "$T1" |
|
33 | grep '^HG: manifest hash' "$1" | cut -b 5- >> "$T1" | |
32 | # Add all other state information |
|
34 | # Add all other state information | |
33 | grep -v '^HG: manifest hash' "$1" >> "$T1" |
|
35 | grep -v '^HG: manifest hash' "$1" >> "$T1" | |
34 | ( |
|
36 | ( | |
35 | cd "`hg root`" |
|
37 | cd "`hg root`" | |
36 | grep '^HG: changed' "$1" | cut -b 13- | while read changed; do |
|
38 | grep '^HG: changed' "$1" | cut -b 13- | while read changed; do | |
37 | hg diff "$changed" >> "$T2" |
|
39 | hg diff "$changed" >> "$T2" | |
38 | done |
|
40 | done | |
39 | ) |
|
41 | ) | |
40 |
|
42 | |||
41 | CHECKSUM=`md5sum "$T1"` |
|
43 | CHECKSUM=`md5sum "$T1"` | |
42 | $EDITOR "$T1" "$T2" || cleanup_exit $? |
|
44 | $EDITOR "$T1" "$T2" || cleanup_exit $? | |
43 | echo "$CHECKSUM" | md5sum -c --status && cleanup_exit 13 |
|
45 | echo "$CHECKSUM" | md5sum -c --status && cleanup_exit 13 | |
44 | { |
|
46 | { | |
45 | head -n 1 "$T1" |
|
47 | head -n 1 "$T1" | |
46 | echo |
|
48 | echo | |
47 |
grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER |
|
49 | grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign | |
48 | } > "$T2" && mv "$T2" "$1" |
|
50 | } > "$T2" && mv "$T2" "$1" | |
49 | cleanup_exit $? |
|
51 | cleanup_exit $? | |
50 | fi |
|
52 | fi | |
51 |
|
53 |
General Comments 0
You need to be logged in to leave comments.
Login now