##// END OF EJS Templates
hgmerge: fix diff+patch detection; cleanups...
Radoslaw Szkodzinski -
r1770:4eea6a74 default
parent child Browse files
Show More
@@ -17,31 +17,33 fi
17 17
18 18 # find decent versions of our utilities, insisting on the GNU versions where we
19 19 # need to
20 MERGE=merge
21 DIFF3=gdiff3
22 DIFF=gdiff
23 PATCH=gpatch
20 MERGE="merge"
21 DIFF3="gdiff3"
22 DIFF="gdiff"
23 PATCH="gpatch"
24 24
25 type $MERGE >/dev/null 2>&1 || MERGE=
26 type $DIFF3 >/dev/null 2>&1 || DIFF3=diff3
27 type $DIFF >/dev/null 2>&1 || DIFF=diff
28 type $PATCH >/dev/null 2>&1 || PATCH=patch
25 type "$MERGE" >/dev/null 2>&1 || MERGE=
26 type "$DIFF3" >/dev/null 2>&1 || DIFF3="diff3"
29 27 $DIFF3 --version >/dev/null 2>&1 || DIFF3=
28 type "$DIFF" >/dev/null 2>&1 || DIFF="diff"
29 type "$DIFF" >/dev/null 2>&1 || DIFF=
30 type "$PATCH" >/dev/null 2>&1 || PATCH="patch"
31 type "$PATCH" >/dev/null 2>&1 || PATCH=
30 32
31 33 # find optional visual utilities
32 FILEMERGE='/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge'
33 KDIFF3=kdiff3
34 TKDIFF=tkdiff
34 FILEMERGE="/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge"
35 KDIFF3="kdiff3"
36 TKDIFF="tkdiff"
35 37
36 type $FILEMERGE >/dev/null 2>&1 || FILEMERGE=
37 type $KDIFF3 >/dev/null 2>&1 || KDIFF3=
38 type $TKDIFF >/dev/null 2>&1 || TKDIFF=
38 type "$FILEMERGE" >/dev/null 2>&1 || FILEMERGE=
39 type "$KDIFF3" >/dev/null 2>&1 || KDIFF3=
40 type "$TKDIFF" >/dev/null 2>&1 || TKDIFF=
39 41
40 42 # random part of names
41 RAND="$RANDOM.$RANDOM.$RANDOM.$$"
43 RAND="$RANDOM$RANDOM"
42 44
43 45 # temporary directory for diff+patch merge
44 HGTMP="${TMPDIR-/tmp}/hgmerge.$RAND"
46 HGTMP="${TMPDIR-'/tmp'}/hgmerge.$RAND"
45 47
46 48 # backup file
47 49 BACKUP="$LOCAL.orig.$RAND"
@@ -76,19 +78,18 mv "$LOCAL" "$BACKUP"
76 78 cp "$BACKUP" "$LOCAL"
77 79
78 80 # Attempt to do a non-interactive merge
81 if [ -n "$MERGE" -o -n "$DIFF3" ]; then
79 82 if [ -n "$MERGE" ]; then
80 83 $MERGE "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && success
81 cp "$BACKUP" "$LOCAL"
82 84 elif [ -n "$DIFF3" ]; then
83 echo $DIFF3 -m "$BACKUP" "$BASE" "$OTHER"
84 85 $DIFF3 -m "$BACKUP" "$BASE" "$OTHER" > "$LOCAL" && success
85 if [ $? -eq 2 ]; then
86 echo "$DIFF3 failed! Exiting." 1>&2
87 cp "$BACKUP" "$LOCAL"
86 fi
87 if [ $? -gt 1 ]; then
88 echo "automatic merge failed! Exiting." 1>&2
88 89 failure
89 90 fi
91 fi
90 92 cp "$BACKUP" "$LOCAL"
91 fi
92 93
93 94 # on MacOS X try FileMerge.app, shipped with Apple's developer tools
94 95 if [ -n "$FILEMERGE" ]; then
General Comments 0
You need to be logged in to leave comments. Login now