comparison hgmerge @ 1772:b1a7fd503a29

hgmerge: logic changes Details: - keep automatic merge conflicts in $LOCAL - do not assume that $EDITOR returns proper error code - fix a slight mistake in diff+patch merge success detection (it could succeed if the $EDITOR failed to run)
author Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
date Tue, 21 Feb 2006 15:48:16 -0600
parents e22bbca2e82b
children aae93c3bffb4
comparison
equal deleted inserted replaced
1771:e22bbca2e82b 1772:b1a7fd503a29
99 if [ $? -gt 1 ]; then 99 if [ $? -gt 1 ]; then
100 echo "automatic merge failed! Exiting." 1>&2 100 echo "automatic merge failed! Exiting." 1>&2
101 failure 101 failure
102 fi 102 fi
103 fi 103 fi
104 cp "$BACKUP" "$LOCAL"
105 104
106 # on MacOS X try FileMerge.app, shipped with Apple's developer tools 105 # on MacOS X try FileMerge.app, shipped with Apple's developer tools
107 if [ -n "$FILEMERGE" ]; then 106 if [ -n "$FILEMERGE" ]; then
108 cp "$BACKUP" "$LOCAL" 107 cp "$BACKUP" "$LOCAL"
109 cp "$BACKUP" "$CHGTEST" 108 cp "$BACKUP" "$CHGTEST"
110 # filemerge prefers the right by default 109 # filemerge prefers the right by default
111 $FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL" 110 $FILEMERGE -left "$OTHER" -right "$LOCAL" -ancestor "$BASE" -merge "$LOCAL"
112 [ $? -ne 0 ] && echo "FileMerge failed to launch" && failure 111 [ $? -ne 0 ] && echo "FileMerge failed to launch" && failure
113 test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged 112 test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
114 failure
115 fi 113 fi
116 114
117 if [ -n "$DISPLAY" ]; then 115 if [ -n "$DISPLAY" ]; then
118 # try using kdiff3, which is fairly nice 116 # try using kdiff3, which is fairly nice
119 if [ -n "$KDIFF3" ]; then 117 if [ -n "$KDIFF3" ]; then
127 success 125 success
128 fi 126 fi
129 fi 127 fi
130 128
131 # Attempt to do a merge with $EDITOR 129 # Attempt to do a merge with $EDITOR
132 if [ -n "$MERGE" ]; then 130 if [ -n "$MERGE" -o -n "$DIFF3" ]; then
133 echo "conflicts detected in $LOCAL" 131 echo "conflicts detected in $LOCAL"
134 $MERGE "$LOCAL" "$BASE" "$OTHER" 2>/dev/null || $EDITOR "$LOCAL" 132 cp "$BACKUP" "$CHGTEST"
135 success 133 $EDITOR "$LOCAL" || failure
136 fi 134 # Some editors do not return meaningful error codes
137 135 # Do not take any chances
138 if [ -n "$DIFF3" ]; then 136 test "$LOCAL" -nt "$CHGTEST" && success || ask_if_merged
139 echo "conflicts detected in $LOCAL"
140 $DIFF3 -m "$BACKUP" "$BASE" "$OTHER" > "$LOCAL" || {
141 case $? in
142 1)
143 $EDITOR "$LOCAL" ;;
144 2) echo "$DIFF3 failed! Exiting." 1>&2
145 cp "$BACKUP" "$LOCAL"
146 failure ;;
147 esac
148 success
149 }
150 fi 137 fi
151 138
152 # attempt to manually merge with diff and patch 139 # attempt to manually merge with diff and patch
153 if [ -n "$DIFF" -a -n "$PATCH" ]; then 140 if [ -n "$DIFF" -a -n "$PATCH" ]; then
154 141
160 $DIFF -u "$BASE" "$OTHER" > "$HGTMP/diff" || : 147 $DIFF -u "$BASE" "$OTHER" > "$HGTMP/diff" || :
161 if $PATCH "$LOCAL" < "$HGTMP/diff"; then 148 if $PATCH "$LOCAL" < "$HGTMP/diff"; then
162 success 149 success
163 else 150 else
164 # If rejects are empty after using the editor, merge was ok 151 # If rejects are empty after using the editor, merge was ok
165 $EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || success 152 $EDITOR "$LOCAL" "$LOCAL.rej" || failure
153 test -s "$LOCAL.rej" || success
166 fi 154 fi
167 failure 155 failure
168 fi 156 fi
169 157
170 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!" 158 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"