[PATCH 2 of 3] merge: provide *_ISLINK environment vars to merge helper

Steve Borho steve at borho.org
Fri Oct 5 16:46:14 UTC 2007


On Fri, 2007-10-05 at 10:23 -0500, Matt Mackall wrote:
> On Fri, Oct 05, 2007 at 12:55:43AM +0200, Patrick Mezard wrote:
> > # HG changeset patch
> > # User Patrick Mezard <pmezard at gmail.com>
> > # Date 1191445776 -7200
> > # Node ID 51655b6b134e2bb19ba75e65e6bdc82108a563bb
> > # Parent  1f29a31ea5ba0aab660c18e5678942e82d462be6
> > merge: provide *_ISLINK environment vars to merge helper
> > 
> > Sets HG_MY_ISLINK, HG_OTHER_ISLINK, HG_BASE_ISLINK in environment. Without these variables, it's impossible for the merge application to know whether the 'other' and 'base' files were symlinks in their original contexts. For the purposes of the merge they are always emitted as small text files.
> 
> If they have a filename and a revision id, it certainly is possible to
> know: just ask hg.

The merge script does have both pieces of info, via the HG_FILE and
HG_OTHER_NODE environment variables, but calling back into hg can be
problematic (hgk suffers this problem, forcing the user to set HG in
their environment).  

Since there's no way for the merge script to know that it needs to query
that info, it would be forced to perform the checks each time.  This
wouldn't be as bad if there was a way for Mercurial to call the merge
script as a python routine (in the same way python hooks can be called).
But Mercurial might as well provide the values up front if the merge
script will need them every time.

Perhaps this could be solved in a different way.  Is there any reason
not to call util.set_link() on the base and other temp files when
applicable?  That would eliminate the ambiguity.

BTW: Is there a command that tells you whether a file is a symlink?
I've tried various forms of the manifest command with no success.

> > diff --git a/mercurial/merge.py b/mercurial/merge.py
> > --- a/mercurial/merge.py
> > +++ b/mercurial/merge.py
> > @@ -17,6 +17,8 @@ def filemerge(repo, fw, fd, fo, wctx, mc
> >      fo = filename in other parent
> >      wctx, mctx = working and merge changecontexts
> >      """
> > +    def islink(fctx):
> > +        return 'l' in fctx.fileflags()
> 
> Perhaps filectx objects should have islink and isexec methods?
> 
-- 
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