[PATCH] Use KDiff3's labeling capability

tailgunner at smtp.ru tailgunner at smtp.ru
Tue Feb 13 22:16:47 UTC 2007


KDiff3 is able to label files being merged - we label them 
with names of the branches they come from.

diff -r 0f35560bc179 -r b36c8f543f08 hgmerge
--- a/hgmerge	Wed Feb 14 01:05:09 2007 +0300
+++ b/hgmerge	Wed Feb 14 01:05:09 2007 +0300
@@ -81,6 +81,15 @@ failure() {
     mv "$BACKUP" "$LOCAL"
     cleanup
     exit 1
+}
+
+file_label() {
+	brname=$(hg log -r $1 | grep ^branch: | awk '{print $2}')
+	if [ -n "$brname" ]; then
+		echo "[$2 branch: $brname] $HG_FILE"
+	else
+		echo "[$2] $HG_FILE"
+	fi
 }
 
 # Ask if the merge was successful
@@ -116,6 +125,11 @@ if [ -n "$MERGE" -o -n "$DIFF3" ]; then
     fi
 fi
 
+# some merge tools (kdiff3) allow us to label the files being merged
+OTHER_LABEL=$(file_label $HG_OTHER_NODE other)
+MY_LABEL=$(file_label $HG_MY_NODE my)
+BASE_LABEL="[base revision]"
+
 # on MacOS X try FileMerge.app, shipped with Apple's developer tools
 if [ -n "$FILEMERGE" ]; then
     cp "$BACKUP" "$LOCAL"
@@ -129,7 +143,8 @@ if [ -n "$DISPLAY" ]; then
 if [ -n "$DISPLAY" ]; then
     # try using kdiff3, which is fairly nice
     if [ -n "$KDIFF3" ]; then
-        $KDIFF3 --auto "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" || failure
+        $KDIFF3 --L1 "$BASE_LABEL" --L2 "$MY_LABEL" --L3 "$OTHER_LABEL" \
+		--auto "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" || failure
         success
     fi
 



More information about the Mercurial-devel mailing list