##// END OF EJS Templates
Fix use of diff(1) triggered by set -e....
levon@movementarian.org -
r1434:696851b1 default
parent child Browse files
Show More
@@ -15,6 +15,17 b' if [ -z "$EDITOR" ]; then'
15 15 EDITOR="vi"
16 16 fi
17 17
18 # find decent versions of our utilities, insisting on the GNU versions where we
19 # need to
20 DIFF3=gdiff3
21 DIFF=gdiff
22 PATCH=gpatch
23
24 type $DIFF3 >/dev/null 2>&1 || DIFF3=diff3
25 type $DIFF >/dev/null 2>&1 || DIFF=diff
26 type $PATCH >/dev/null 2>&1 || PATCH=patch
27 $DIFF3 --version >/dev/null 2>&1 || DIFF3=
28
18 29 # Back up our file
19 30 cp "$LOCAL" "$LOCAL.orig"
20 31
@@ -22,8 +33,14 b' cp "$LOCAL" "$LOCAL.orig"'
22 33 if type merge > /dev/null 2>&1; then
23 34 merge "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && exit 0
24 35 cp "$LOCAL.orig" "$LOCAL"
25 elif type diff3 > /dev/null 2>&1; then
26 diff3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" && exit 0
36 elif [ -n "$DIFF3" ]; then
37 echo $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER"
38 $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" && exit 0
39 if [ $? -eq 2 ]; then
40 echo "$DIFF3 failed! Exiting." 1>&2
41 cp "$LOCAL.orig" "$LOCAL"
42 exit 1
43 fi
27 44 cp "$LOCAL.orig" "$LOCAL"
28 45 fi
29 46
@@ -48,10 +65,18 b' if type merge > /dev/null 2>&1; then'
48 65 exit 0
49 66 fi
50 67
51 if type diff3 > /dev/null 2>&1; then
68 if [ -n "$DIFF3" ]; then
52 69 echo "conflicts detected in $LOCAL"
53 diff3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" || $EDITOR "$LOCAL"
54 exit 0
70 $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" || {
71 case $? in
72 1)
73 $EDITOR "$LOCAL" ;;
74 2) echo "$DIFF3 failed! Exiting." 1>&2
75 cp "$LOCAL.orig" "$LOCAL"
76 exit 1 ;;
77 esac
78 exit 0
79 }
55 80 fi
56 81
57 82 HGTMP=""
@@ -60,7 +85,7 b' cleanup_exit() {'
60 85 }
61 86
62 87 # attempt to manually merge with diff and patch
63 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
88 if [ -n "$DIFF" -a -n "$PATCH" ]; then
64 89 # Remove temporary files even if we get interrupted
65 90 trap "cleanup_exit" 0 # normal exit
66 91 trap "exit 1" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
@@ -71,8 +96,8 b' if type diff > /dev/null 2>&1 && type pa'
71 96 exit 1
72 97 }
73 98
74 diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
75 if patch "$LOCAL" < "$HGTMP/diff"; then
99 $DIFF -u "$BASE" "$OTHER" > "$HGTMP/diff" || :
100 if $PATCH "$LOCAL" < "$HGTMP/diff"; then
76 101 exit 0
77 102 else
78 103 # If rejects are empty after using the editor, merge was ok
General Comments 0
You need to be logged in to leave comments. Login now