[PATCH] Improved logging for filemerge, making it easier to debug bogus merge configuration

Mads Kiilerich mads at kiilerich.com
Mon Sep 15 08:02:49 CDT 2008


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1221483638 -7200
# Node ID 34c4bb8030ff653a711892d03d77f8894b762608
# Parent  0d513661d6c280fae68a96aea16231702959bfb6
Improved logging for filemerge, making it easier to debug bogus merge configuration

diff -r 0d513661d6c2 -r 34c4bb8030ff mercurial/filemerge.py
--- a/mercurial/filemerge.py	Sat Sep 13 10:46:47 2008 -0500
+++ b/mercurial/filemerge.py	Mon Sep 15 15:00:38 2008 +0200
@@ -53,8 +53,8 @@
     for pat, tool in ui.configitems("merge-patterns"):
         mf = util.matcher(repo.root, "", [pat], [], [])[1]
         if mf(path) and check(tool, pat, symlink, False):
-                toolpath = _findtool(ui, tool)
-                return (tool, '"' + toolpath + '"')
+            toolpath = _findtool(ui, tool)
+            return (tool, '"' + toolpath + '"')
 
     # then merge tools
     tools = {}
@@ -72,8 +72,11 @@
     tools.append((None, "hgmerge")) # the old default, if found
     for p,t in tools:
         toolpath = _findtool(ui, t)
-        if toolpath and check(t, None, symlink, binary):
-            return (t, '"' + toolpath + '"')
+        if toolpath:
+            if check(t, None, symlink, binary):
+                return (t, '"' + toolpath + '"')
+        else:
+            repo.ui.warn(_("merge tool '%s' not found\n") % t)
     # internal merge as last resort
     return (not (symlink or binary) and "internal:merge" or None, None)
 
@@ -169,7 +172,7 @@
     if _toolbool(ui, tool, "premerge", not (binary or symlink)):
         r = simplemerge.simplemerge(a, b, c, quiet=True)
         if not r:
-            ui.debug(_(" premerge successful\n"))
+            ui.debug(_("premerge successful and sufficient\n"))
             os.unlink(back)
             os.unlink(b)
             os.unlink(c)
@@ -192,7 +195,9 @@
         replace = dict(local=a, base=b, other=c, output=out)
         args = re.sub("\$(local|base|other|output)",
                       lambda x: '"%s"' % replace[x.group()[1:]], args)
-        r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env)
+        cmd = toolpath + ' ' + args
+        ui.debug(_("executing %r\n") % cmd)
+        r = util.system(cmd, cwd=repo.root, environ=env)
 
     if not r and _toolbool(ui, tool, "checkconflicts"):
         if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()):


More information about the Mercurial-devel mailing list