[PATCH] filemerge: wrap quotes around tool path

Steve Borho steve at borho.org
Mon Feb 4 13:52:04 CST 2008


On Mon, 2008-02-04 at 13:23 -0600, Matt Mackall wrote:
> On Mon, 2008-02-04 at 12:33 -0600, Steve Borho wrote:
> > # HG changeset patch
> > # User Steve Borho <steve at borho.org>
> > # Date 1202147114 21600
> > # Node ID 1da25064cd8eb0278fd3414b78a16a0f8729cf96
> > # 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
> > @@ -184,7 +184,7 @@
> >          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)
> > +        r = util.system('"'+toolpath+'" '+args, cwd=repo.root, environ=env)
> >  
> >      if not r and _toolbool(ui, tool, "checkconflicts"):
> >          if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcm.data()):
> 
> Hmm, that breaks things like:
> 
> HGMERGE=script -with -some -other -args
> 
> We were using precisely that trick in run-tests.py until yesterday, so I
> suspect other people are using it too.
> 
> Please describe what you're trying to fix. I suspect it'd be better to
> introduce quotes in _findtool().

Slightly off-topic, but a feature that both hgmerge(.sh) and hgmerge.py
had but is currently not present in the new filemerge is that they
detected when a merge tool exits without changing the output file, but
still reports success.  This caught many of the messier failure cases.

I wrote this patch to catch the problem, but the file comparison doesn't
work and I don't know why.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -193,6 +193,12 @@
     if _toolbool(ui, tool, "fixeol"):
         _matcheol(repo.wjoin(fd), back)
 
+    if not r and not fcm.cmp(wctx.filectx(fd).data()):
+        if ui.prompt(_(" output file %s appears unchanged\n"
+                       "was merge successful (yn)?") % fd,
+                     _("[yn]"), _("n")) != _("y"):
+            r = 1
+
     if r:
         repo.ui.warn(_("merging %s failed!\n") % fd)
     else:

-- 
Steve Borho (steve at borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C



More information about the Mercurial-devel mailing list