[PATCH] filemerge: wrap quotes around tool path

Matt Mackall mpm at selenic.com
Mon Feb 4 15:23:28 CST 2008


On Mon, 2008-02-04 at 15:03 -0600, Steve Borho wrote:
> On Mon, 2008-02-04 at 18:20 -0200, Alexis S. L. Carvalho wrote:
> > Thus spake Steve Borho:
> > > 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
> > > +
> > 
> > fcm is a workingfilectx.  Its cmp method reads the file from the working
> > dir and compares it with the string that you passed, which is the exact
> > same thing.
> 
> That would explain it, thanks.
> 
> Is there an efficient way to tell whether the work copy file differs
> from the first parent in this context?

If you want to limit yourself to one copy in memory, you can do a hash
before merge and a hash after. Otherwise just compare against the orig
file before we delete it.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list