mirror of
https://github.com/facebook/sapling.git
synced 2025-01-08 14:46:47 +03:00
basefilectx: move cmp from filectx
This commit is contained in:
parent
29424e6c91
commit
b4bfc8c2dc
@ -523,6 +523,21 @@ class basefilectx(object):
|
|||||||
except IOError:
|
except IOError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def cmp(self, fctx):
|
||||||
|
"""compare with other file context
|
||||||
|
|
||||||
|
returns True if different than fctx.
|
||||||
|
"""
|
||||||
|
if (fctx._filerev is None
|
||||||
|
and (self._repo._encodefilterpats
|
||||||
|
# if file data starts with '\1\n', empty metadata block is
|
||||||
|
# prepended, which adds 4 bytes to filelog.size().
|
||||||
|
or self.size() - 4 == fctx.size())
|
||||||
|
or self.size() == fctx.size()):
|
||||||
|
return self._filelog.cmp(self._filenode, fctx.data())
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class filectx(basefilectx):
|
class filectx(basefilectx):
|
||||||
"""A filecontext object makes access to data related to a particular
|
"""A filecontext object makes access to data related to a particular
|
||||||
filerevision convenient."""
|
filerevision convenient."""
|
||||||
@ -583,21 +598,6 @@ class filectx(basefilectx):
|
|||||||
def size(self):
|
def size(self):
|
||||||
return self._filelog.size(self._filerev)
|
return self._filelog.size(self._filerev)
|
||||||
|
|
||||||
def cmp(self, fctx):
|
|
||||||
"""compare with other file context
|
|
||||||
|
|
||||||
returns True if different than fctx.
|
|
||||||
"""
|
|
||||||
if (fctx._filerev is None
|
|
||||||
and (self._repo._encodefilterpats
|
|
||||||
# if file data starts with '\1\n', empty metadata block is
|
|
||||||
# prepended, which adds 4 bytes to filelog.size().
|
|
||||||
or self.size() - 4 == fctx.size())
|
|
||||||
or self.size() == fctx.size()):
|
|
||||||
return self._filelog.cmp(self._filenode, fctx.data())
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def renamed(self):
|
def renamed(self):
|
||||||
"""check if file was actually renamed in this changeset revision
|
"""check if file was actually renamed in this changeset revision
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user