##// END OF EJS Templates
Cleaned up trap handling:...
Thomas Arendsen Hein -
r831:232d0616 default
parent child Browse files
Show More
@@ -24,11 +24,11 b' esac'
24 HGTMP=""
24 HGTMP=""
25 cleanup_exit() {
25 cleanup_exit() {
26 rm -rf "$HGTMP"
26 rm -rf "$HGTMP"
27 exit $1
28 }
27 }
29
28
30 # Remove temporary files even if we get interrupted
29 # Remove temporary files even if we get interrupted
31 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
30 trap "cleanup_exit" 0 # normal exit
31 trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
32
32
33 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
33 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
34 (umask 077 && mkdir "$HGTMP") || {
34 (umask 077 && mkdir "$HGTMP") || {
@@ -51,8 +51,8 b' fi'
51 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg"
51 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg"
52
52
53 CHECKSUM=`md5sum "$HGTMP/msg"`
53 CHECKSUM=`md5sum "$HGTMP/msg"`
54 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || cleanup_exit $?
54 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
55 echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && cleanup_exit 13
55 echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && exit 13
56
56
57 if [ "$SIGN" == "1" ]; then
57 if [ "$SIGN" == "1" ]; then
58 {
58 {
@@ -64,4 +64,4 b' else'
64 mv "$HGTMP/msg" "$1"
64 mv "$HGTMP/msg" "$1"
65 fi
65 fi
66
66
67 cleanup_exit $?
67 exit $?
@@ -57,13 +57,13 b' fi'
57 HGTMP=""
57 HGTMP=""
58 cleanup_exit() {
58 cleanup_exit() {
59 rm -rf "$HGTMP"
59 rm -rf "$HGTMP"
60 exit $1
61 }
60 }
62
61
63 # attempt to manually merge with diff and patch
62 # attempt to manually merge with diff and patch
64 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
63 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
65 # Remove temporary files even if we get interrupted
64 # Remove temporary files even if we get interrupted
66 trap "cleanup_exit 1" TERM KILL INT QUIT ABRT
65 trap "cleanup_exit" 0 # normal exit
66 trap "exit 1" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
67
67
68 HGTMP="${TMPDIR-/tmp}/hgmerge.$RANDOM.$RANDOM.$RANDOM.$$"
68 HGTMP="${TMPDIR-/tmp}/hgmerge.$RANDOM.$RANDOM.$RANDOM.$$"
69 (umask 077 && mkdir "$HGTMP") || {
69 (umask 077 && mkdir "$HGTMP") || {
@@ -73,12 +73,12 b' if type diff > /dev/null 2>&1 && type pa'
73
73
74 diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
74 diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
75 if patch "$LOCAL" < "$HGTMP/diff"; then
75 if patch "$LOCAL" < "$HGTMP/diff"; then
76 cleanup_exit 0
76 exit 0
77 else
77 else
78 # If rejects are empty after using the editor, merge was ok
78 # If rejects are empty after using the editor, merge was ok
79 $EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || cleanup_exit 0
79 $EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || exit 0
80 fi
80 fi
81 cleanup_exit 1
81 exit 1
82 fi
82 fi
83
83
84 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
84 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
General Comments 0
You need to be logged in to leave comments. Login now