Show More
@@ -1,57 +1,57 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 | # change this to one to turn on GPG support |
|
7 | 7 | SIGN=0 |
|
8 | 8 | |
|
9 | 9 | T1=""; T2="" |
|
10 | 10 | cleanup_exit() { |
|
11 | 11 | rm -f "$T1" "$T2" |
|
12 | 12 | exit $1 |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | # If you want to pass your favourite editor some other parameters |
|
16 | 16 | # only for Mercurial, modify this: |
|
17 | 17 | case "${EDITOR:=vi}" in |
|
18 | 18 | emacs) |
|
19 | 19 | EDITOR="$EDITOR -nw" |
|
20 | 20 | ;; |
|
21 | 21 | gvim|vim) |
|
22 | 22 | EDITOR="$EDITOR -f -o" |
|
23 | 23 | ;; |
|
24 | 24 | esac |
|
25 | 25 | |
|
26 | 26 | # Remove temporary files even if we get interrupted |
|
27 | 27 | trap "cleanup_exit 255" TERM KILL INT QUIT ABRT |
|
28 | 28 | T1=`mktemp`; T2=`mktemp` |
|
29 | 29 | ( |
|
30 | 30 | cd "`hg root`" |
|
31 | 31 | grep '^HG: changed' "$1" | cut -b 13- | while read changed; do |
|
32 | 32 | hg diff "$changed" >> "$T2" |
|
33 | 33 | done |
|
34 | 34 | ) |
|
35 | 35 | |
|
36 | 36 | echo > "$T1" |
|
37 | 37 | if [ "$SIGN" == "1" ]; then |
|
38 | 38 | MANIFEST=`grep '^HG: manifest hash' "$1" | cut -b 19-` |
|
39 | 39 | echo -e "\nmanifest hash: $MANIFEST" >> "$T1" |
|
40 | 40 | fi |
|
41 | 41 | grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$T1" |
|
42 | 42 | |
|
43 | 43 | CHECKSUM=`md5sum "$T1"` |
|
44 | 44 | $EDITOR "$T1" "$T2" || cleanup_exit $? |
|
45 |
echo "$CHECKSUM" | md5sum -c |
|
|
45 | echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && cleanup_exit 13 | |
|
46 | 46 | |
|
47 | 47 | if [ "$SIGN" == "1" ]; then |
|
48 | 48 | { |
|
49 | 49 | head -n 1 "$T1" |
|
50 | 50 | echo |
|
51 | 51 | grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign |
|
52 | 52 | } > "$T2" && mv "$T2" "$1" |
|
53 | 53 | else |
|
54 | 54 | mv "$T1" "$1" |
|
55 | 55 | fi |
|
56 | 56 | |
|
57 | 57 | cleanup_exit $? |
General Comments 0
You need to be logged in to leave comments.
Login now