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

Patrick Mezard pmezard at gmail.com
Thu Oct 4 17:55:43 CDT 2007


# 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.

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()
 
     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