[PATCH 1 of 2] Provide *_ISLINK environment vars to merge helper

Steve Borho steve at borho.org
Mon Oct 1 01:43:03 UTC 2007


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1191202867 18000
# Node ID f8b4e3545651be6e19adea9480e633d65813fd69
# Parent  9189ae05467d36217f85970b585177bb5bcdc23b
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.

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.manifest().flags(fctx.path()) and '1' or '0'
 
     def temp(prefix, ctx):
         pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
@@ -53,7 +55,10 @@ def filemerge(repo, fw, fd, fo, wctx, mc
     r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=repo.root,
                     environ={'HG_FILE': fd,
                              'HG_MY_NODE': str(wctx.parents()[0]),
-                             'HG_OTHER_NODE': str(mctx)})
+                             'HG_OTHER_NODE': str(mctx),
+                             'HG_MY_ISLINK': islink(fcm),
+                             'HG_OTHER_ISLINK': islink(fco),
+                             'HG_BASE_ISLINK': islink(fca),})
     if r:
         repo.ui.warn(_("merging %s failed!\n") % fd)
 


More information about the Mercurial-devel mailing list