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