Show More
@@ -15,6 +15,17 b' if [ -z "$EDITOR" ]; then' | |||||
15 | EDITOR="vi" |
|
15 | EDITOR="vi" | |
16 | fi |
|
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 | # Back up our file |
|
29 | # Back up our file | |
19 | cp "$LOCAL" "$LOCAL.orig" |
|
30 | cp "$LOCAL" "$LOCAL.orig" | |
20 |
|
31 | |||
@@ -22,8 +33,14 b' cp "$LOCAL" "$LOCAL.orig"' | |||||
22 | if type merge > /dev/null 2>&1; then |
|
33 | if type merge > /dev/null 2>&1; then | |
23 | merge "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && exit 0 |
|
34 | merge "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && exit 0 | |
24 | cp "$LOCAL.orig" "$LOCAL" |
|
35 | cp "$LOCAL.orig" "$LOCAL" | |
25 | elif type diff3 > /dev/null 2>&1; then |
|
36 | elif [ -n "$DIFF3" ]; then | |
26 |
|
|
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 | cp "$LOCAL.orig" "$LOCAL" |
|
44 | cp "$LOCAL.orig" "$LOCAL" | |
28 | fi |
|
45 | fi | |
29 |
|
46 | |||
@@ -48,10 +65,18 b' if type merge > /dev/null 2>&1; then' | |||||
48 | exit 0 |
|
65 | exit 0 | |
49 | fi |
|
66 | fi | |
50 |
|
67 | |||
51 | if type diff3 > /dev/null 2>&1; then |
|
68 | if [ -n "$DIFF3" ]; then | |
52 | echo "conflicts detected in $LOCAL" |
|
69 | echo "conflicts detected in $LOCAL" | |
53 |
|
|
70 | $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" || { | |
54 | exit 0 |
|
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 | fi |
|
80 | fi | |
56 |
|
81 | |||
57 | HGTMP="" |
|
82 | HGTMP="" | |
@@ -60,7 +85,7 b' cleanup_exit() {' | |||||
60 | } |
|
85 | } | |
61 |
|
86 | |||
62 | # attempt to manually merge with diff and patch |
|
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 | # Remove temporary files even if we get interrupted |
|
89 | # Remove temporary files even if we get interrupted | |
65 | trap "cleanup_exit" 0 # normal exit |
|
90 | trap "cleanup_exit" 0 # normal exit | |
66 | trap "exit 1" 1 2 3 6 15 # HUP INT QUIT ABRT TERM |
|
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 | exit 1 |
|
96 | exit 1 | |
72 | } |
|
97 | } | |
73 |
|
98 | |||
74 |
|
|
99 | $DIFF -u "$BASE" "$OTHER" > "$HGTMP/diff" || : | |
75 |
if |
|
100 | if $PATCH "$LOCAL" < "$HGTMP/diff"; then | |
76 | exit 0 |
|
101 | exit 0 | |
77 | else |
|
102 | else | |
78 | # If rejects are empty after using the editor, merge was ok |
|
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