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