mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
filectx: allow custom comparators
We're going to introduce other sorts of filectxes very soon, and we'd like the cmp method to function properly (i.e. commutatively) for them. The only way to make that happen is for this cmp method to call into that specialized one if that defines a custom comparator.
This commit is contained in:
parent
c7aefbc8d6
commit
6a83f7850c
@ -747,11 +747,15 @@ class basefilectx(object):
|
|||||||
def islink(self):
|
def islink(self):
|
||||||
return 'l' in self.flags()
|
return 'l' in self.flags()
|
||||||
|
|
||||||
|
_customcmp = False
|
||||||
def cmp(self, fctx):
|
def cmp(self, fctx):
|
||||||
"""compare with other file context
|
"""compare with other file context
|
||||||
|
|
||||||
returns True if different than fctx.
|
returns True if different than fctx.
|
||||||
"""
|
"""
|
||||||
|
if fctx._customcmp:
|
||||||
|
return fctx.cmp(self)
|
||||||
|
|
||||||
if (fctx._filerev is None
|
if (fctx._filerev is None
|
||||||
and (self._repo._encodefilterpats
|
and (self._repo._encodefilterpats
|
||||||
# if file data starts with '\1\n', empty metadata block is
|
# if file data starts with '\1\n', empty metadata block is
|
||||||
|
Loading…
Reference in New Issue
Block a user