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

login
register
mail settings
Submitter phabricator
Date Oct. 16, 2017, 7:01 p.m.
Message ID <differential-rev-PHID-DREV-vwnawqsvprk45xnrfu5c-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25029/
State Superseded
Headers show

Comments

phabricator - Oct. 16, 2017, 7:01 p.m.
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




To: phillco, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 17, 2017, 10:29 a.m.
ryanmce added a comment.


  Hm, check-code is failing here.

REPOSITORY
  rHG Mercurial

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

To: phillco, #hg-reviewers, durin42
Cc: ryanmce, mercurial-devel
phabricator - Oct. 17, 2017, 11:47 a.m.
ryanmce added a comment.


  I'm dropping this from hg-committed for now. Please re-submit with the check-code issues fixed.
  
  @hg-reviewers: If I'm doing this wrong by dropping the patch, please let me know so I can correct my behavior in the future.

INLINE COMMENTS

> test-arbitraryfilectx.t:53
> +  $ hg eval "context.arbitraryfilectx('real_A', repo).cmp(repo[None]['sym_A'])"
> +  False (no-e ol)
> +

why is there a space after the e here?

REPOSITORY
  rHG Mercurial

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

To: phillco, #hg-reviewers, durin42
Cc: ryanmce, mercurial-devel
phabricator - Oct. 17, 2017, 2:31 p.m.
durin42 added a comment.


  No, that sounds fair, Phil should resend (as a new differential ID) when the issue is sorted.

REPOSITORY
  rHG Mercurial

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

To: phillco, #hg-reviewers, durin42
Cc: ryanmce, mercurial-devel
phabricator - Oct. 17, 2017, 7:28 p.m.
phillco added a comment.


  Whoops, sorry, I forgot to run tests on the most recent version. Will fix & resend.

REPOSITORY
  rHG Mercurial

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

To: phillco, #hg-reviewers, durin42
Cc: ryanmce, mercurial-devel
phabricator - Oct. 17, 2017, 7:42 p.m.
phillco added a comment.


  I've sent https://phab.mercurial-scm.org/D1165, which is the corrected version.

REPOSITORY
  rHG Mercurial

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

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

Patch

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