mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
cmp: document the fact that we return True if content is different
This is similar to the __builtin__.cmp behaviour, but still not straightforward, as the dailylife meaning of a comparison usually is "find out if they are different".
This commit is contained in:
parent
d78df2ed54
commit
6e75efdbcb
@ -353,6 +353,10 @@ class filectx(object):
|
|||||||
return self._filelog.size(self._filerev)
|
return self._filelog.size(self._filerev)
|
||||||
|
|
||||||
def cmp(self, text):
|
def cmp(self, text):
|
||||||
|
"""compare text with stored file revision
|
||||||
|
|
||||||
|
returns True if text is different than what is stored.
|
||||||
|
"""
|
||||||
return self._filelog.cmp(self._filenode, text)
|
return self._filelog.cmp(self._filenode, text)
|
||||||
|
|
||||||
def renamed(self):
|
def renamed(self):
|
||||||
@ -932,6 +936,10 @@ class workingfilectx(filectx):
|
|||||||
return (t, tz)
|
return (t, tz)
|
||||||
|
|
||||||
def cmp(self, text):
|
def cmp(self, text):
|
||||||
|
"""compare text with disk content
|
||||||
|
|
||||||
|
returns True if text is different than what is on disk.
|
||||||
|
"""
|
||||||
return self._repo.wread(self._path) != text
|
return self._repo.wread(self._path) != text
|
||||||
|
|
||||||
class memctx(object):
|
class memctx(object):
|
||||||
|
@ -56,7 +56,10 @@ class filelog(revlog.revlog):
|
|||||||
return revlog.revlog.size(self, rev)
|
return revlog.revlog.size(self, rev)
|
||||||
|
|
||||||
def cmp(self, node, text):
|
def cmp(self, node, text):
|
||||||
"""compare text with a given file revision"""
|
"""compare text with a given file revision
|
||||||
|
|
||||||
|
returns True if text is different than what is stored.
|
||||||
|
"""
|
||||||
|
|
||||||
# for renames, we have to go the slow way
|
# for renames, we have to go the slow way
|
||||||
if text.startswith('\1\n') or self.renamed(node):
|
if text.startswith('\1\n') or self.renamed(node):
|
||||||
|
@ -943,7 +943,10 @@ class revlog(object):
|
|||||||
raise LookupError(id, self.indexfile, _('no match found'))
|
raise LookupError(id, self.indexfile, _('no match found'))
|
||||||
|
|
||||||
def cmp(self, node, text):
|
def cmp(self, node, text):
|
||||||
"""compare text with a given file revision"""
|
"""compare text with a given file revision
|
||||||
|
|
||||||
|
returns True if text is different than what is stored.
|
||||||
|
"""
|
||||||
p1, p2 = self.parents(node)
|
p1, p2 = self.parents(node)
|
||||||
return hash(text, p1, p2) != node
|
return hash(text, p1, p2) != node
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user