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