[PATCH 1 of 2] filemerge: wrap quotes around tool path

Steve Borho steve at borho.org
Mon Feb 4 20:27:08 CST 2008


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1202175514 21600
# Node ID bb87b78bf30a6c3642b04e3a42aea8775fb78f38
# Parent  288ec2f6faa2a362dafa8da81bd03d96e36be5ee
filemerge: wrap quotes around tool path

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -43,14 +43,16 @@
         return False
 
     # HGMERGE takes precedence
-    if os.environ.get("HGMERGE"):
-        return os.environ.get("HGMERGE")
+    hgmerge = os.environ.get("HGMERGE")
+    if hgmerge:
+        return (hgmerge, hgmerge)
 
     # then patterns
     for pat, tool in ui.configitems("merge-patterns"):
         mf = util.matcher(repo.root, "", [pat], [], [])[1]
         if mf(path) and check(tool, pat, symlink, False):
-                return tool
+                toolpath = _findtool(ui, tool)
+                return (tool, '"' + toolpath + '"')
 
     # then merge tools
     tools = {}
@@ -63,10 +65,12 @@
     if ui.config("ui", "merge"):
         tools.insert(0, (None, ui.config("ui", "merge"))) # highest priority
     tools.append((None, "hgmerge")) # the old default, if found
-    tools.append((None, "internal:merge")) # internal merge as last resort
     for p,t in tools:
-        if _findtool(ui, t) and check(t, None, symlink, binary):
-            return t
+        toolpath = _findtool(ui, t)
+        if toolpath and check(t, None, symlink, binary):
+            return (t, '"' + toolpath + '"')
+    # internal merge as last resort
+    return (not (symlink or binary) and "internal:merge" or None, None)
 
 def _eoltype(data):
     "Guess the EOL type of a file"
@@ -124,7 +128,7 @@
     fca = fcm.ancestor(fco) or repo.filectx(fw, fileid=nullrev)
     binary = isbin(fcm) or isbin(fco) or isbin(fca)
     symlink = fcm.islink() or fco.islink()
-    tool = _picktool(repo, ui, fw, binary, symlink)
+    tool, toolpath = _picktool(repo, ui, fw, binary, symlink)
     ui.debug(_("picked tool '%s' for %s (binary %s symlink %s)\n") %
                (tool, fw, binary, symlink))
 
@@ -177,7 +181,6 @@
     if tool == "internal:merge":
         r = simplemerge.simplemerge(a, b, c, label=['local', 'other'])
     else:
-        toolpath = _findtool(ui, tool)
         args = _toolstr(ui, tool, "args", '$local $base $other')
         if "$output" in args:
             out, a = a, back # read input from backup, write to original


More information about the Mercurial-devel mailing list