Mercurial > hg-stable
changeset 11539:a463e3c50212 stable
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".
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Fri, 09 Jul 2010 11:02:39 +0900 |
parents | 16fe98804fd8 |
children | 2370e270a29a |
files | mercurial/context.py mercurial/filelog.py mercurial/revlog.py |
diffstat | 3 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Fri Jul 09 11:59:48 2010 +0900 +++ b/mercurial/context.py Fri Jul 09 11:02:39 2010 +0900 @@ -353,6 +353,10 @@ return self._filelog.size(self._filerev) 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) def renamed(self): @@ -932,6 +936,10 @@ return (t, tz) 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 class memctx(object):
--- a/mercurial/filelog.py Fri Jul 09 11:59:48 2010 +0900 +++ b/mercurial/filelog.py Fri Jul 09 11:02:39 2010 +0900 @@ -56,7 +56,10 @@ return revlog.revlog.size(self, rev) 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 if text.startswith('\1\n') or self.renamed(node):
--- a/mercurial/revlog.py Fri Jul 09 11:59:48 2010 +0900 +++ b/mercurial/revlog.py Fri Jul 09 11:02:39 2010 +0900 @@ -943,7 +943,10 @@ raise LookupError(id, self.indexfile, _('no match found')) 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) return hash(text, p1, p2) != node