comparison hgmerge @ 1699:83e8cd97b9f9

hgmerge: add and use more tool variables This patch adds even more customisable variables with tool paths. Also moves $FILEMERGE where it belongs.
author Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
date Mon, 06 Feb 2006 17:32:00 -0600
parents 4338e33c973b
children e2f91e0acbb8
comparison
equal deleted inserted replaced
1698:ad4a2eefe4d7 1699:83e8cd97b9f9
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 18 # find decent versions of our utilities, insisting on the GNU versions where we
19 # need to 19 # need to
20 MERGE=merge
20 DIFF3=gdiff3 21 DIFF3=gdiff3
21 DIFF=gdiff 22 DIFF=gdiff
22 PATCH=gpatch 23 PATCH=gpatch
23 24
25 type $MERGE >/dev/null 2>&1 || MERGE=
24 type $DIFF3 >/dev/null 2>&1 || DIFF3=diff3 26 type $DIFF3 >/dev/null 2>&1 || DIFF3=diff3
25 type $DIFF >/dev/null 2>&1 || DIFF=diff 27 type $DIFF >/dev/null 2>&1 || DIFF=diff
26 type $PATCH >/dev/null 2>&1 || PATCH=patch 28 type $PATCH >/dev/null 2>&1 || PATCH=patch
27 $DIFF3 --version >/dev/null 2>&1 || DIFF3= 29 $DIFF3 --version >/dev/null 2>&1 || DIFF3=
30
31 # find optional visual utilities
32 FILEMERGE='/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge'
33 KDIFF3=kdiff3
34 TKDIFF=tkdiff
35
36 type $FILEMERGE >/dev/null 2>&1 || FILEMERGE=
37 type $KDIFF3 >/dev/null 2>&1 || KDIFF3=
38 type $TKDIFF >/dev/null 2>&1 || TKDIFF=
28 39
29 # Back up our file 40 # Back up our file
30 cp "$LOCAL" "$LOCAL.orig" 41 cp "$LOCAL" "$LOCAL.orig"
31 42
32 # Attempt to do a non-interactive merge 43 # Attempt to do a non-interactive merge
33 if type merge > /dev/null 2>&1; then 44 if [ -n "$MERGE" ]; then
34 merge "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && exit 0 45 $MERGE "$LOCAL" "$BASE" "$OTHER" 2> /dev/null && exit 0
35 cp "$LOCAL.orig" "$LOCAL" 46 cp "$LOCAL.orig" "$LOCAL"
36 elif [ -n "$DIFF3" ]; then 47 elif [ -n "$DIFF3" ]; then
37 echo $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" 48 echo $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER"
38 $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" && exit 0 49 $DIFF3 -m "$LOCAL.orig" "$BASE" "$OTHER" > "$LOCAL" && exit 0
39 if [ $? -eq 2 ]; then 50 if [ $? -eq 2 ]; then
44 cp "$LOCAL.orig" "$LOCAL" 55 cp "$LOCAL.orig" "$LOCAL"
45 fi 56 fi
46 57
47 # on MacOS X try FileMerge.app, shipped with Apple's developer tools 58 # on MacOS X try FileMerge.app, shipped with Apple's developer tools
48 # TODO: make proper temp files. foo.orig and foo.link are dangerous 59 # TODO: make proper temp files. foo.orig and foo.link are dangerous
49 FILEMERGE='/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge' 60
50 if type "$FILEMERGE" > /dev/null 2>&1; then 61 if [ -n "$FILEMERGE" ]; then
51 cp "$LOCAL.orig" "$LOCAL" 62 cp "$LOCAL.orig" "$LOCAL"
52 ln "$LOCAL" "$LOCAL.link" 63 ln "$LOCAL" "$LOCAL.link"
53 # filemerge prefers the right by default 64 # filemerge prefers the right by default
54 if ! "$FILEMERGE" -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL" 65 if ! "$FILEMERGE" -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
55 then 66 then
77 fi 88 fi
78 fi 89 fi
79 90
80 if [ -n "$DISPLAY" ]; then 91 if [ -n "$DISPLAY" ]; then
81 # try using kdiff3, which is fairly nice 92 # try using kdiff3, which is fairly nice
82 if type kdiff3 > /dev/null 2>&1; then 93 if [ -n "$KDIFF3" ]; then
83 kdiff3 --auto "$BASE" "$LOCAL" "$OTHER" -o "$LOCAL" || exit 1 94 $KDIFF3 --auto "$BASE" "$LOCAL" "$OTHER" -o "$LOCAL" || exit 1
84 exit 0 95 exit 0
85 fi 96 fi
86 97
87 # try using tkdiff, which is a bit less sophisticated 98 # try using tkdiff, which is a bit less sophisticated
88 if type tkdiff > /dev/null 2>&1; then 99 if [ -n "$TKDIFF" ]; then
89 tkdiff "$LOCAL" "$OTHER" -a "$BASE" -o "$LOCAL" || exit 1 100 $TKDIFF "$LOCAL" "$OTHER" -a "$BASE" -o "$LOCAL" || exit 1
90 exit 0 101 exit 0
91 fi 102 fi
92 fi 103 fi
93 104
94 # Attempt to do a merge with $EDITOR 105 # Attempt to do a merge with $EDITOR
95 if type merge > /dev/null 2>&1; then 106 if [ -n "$MERGE" ]; then
96 echo "conflicts detected in $LOCAL" 107 echo "conflicts detected in $LOCAL"
97 merge "$LOCAL" "$BASE" "$OTHER" 2>/dev/null || $EDITOR "$LOCAL" 108 $MERGE "$LOCAL" "$BASE" "$OTHER" 2>/dev/null || $EDITOR "$LOCAL"
98 exit 0 109 exit 0
99 fi 110 fi
100 111
101 if [ -n "$DIFF3" ]; then 112 if [ -n "$DIFF3" ]; then
102 echo "conflicts detected in $LOCAL" 113 echo "conflicts detected in $LOCAL"