D1122: arbitraryfilecontext: skip the cmp fast path if any side is a symlink

phillco (Phil Cohen) phabricator at mercurial-scm.org
Mon Oct 16 19:01:57 UTC 2017


phillco created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1122

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2561,7 +2561,10 @@
         self._path = path
 
     def cmp(self, fctx):
-        if isinstance(fctx, workingfilectx) and self._repo:
+        # filecmp follows symlinks whereas `cmp` should not, so skip the fast
+        # path if either side is a symlink.
+        symlinks = ('l' in self.flags() or 'l' in fctx.flags())
+        if isinstance(fctx, workingfilectx) and self._repo and not symlinks:
             # Add a fast-path for merge if both sides are disk-backed.
             # Note that filecmp uses the opposite return values as cmp.
             return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path()))



To: phillco, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list