changeset 14208:d62d597b8974

revlog: compute correct deltaparent in the deltaparent function It now returns nullrev for chain base revisions, since they are conceptually deltas against nullrev. The revdiff function was updated accordingly.
author Sune Foldager <cryo@cyanite.org>
date Thu, 05 May 2011 18:05:24 +0200
parents c1cca38818b9
children 08d84bdce1a5 e5a59d31bb04
files mercurial/manifest.py mercurial/revlog.py
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Thu May 05 11:33:02 2011 -0400
+++ b/mercurial/manifest.py	Thu May 05 18:05:24 2011 +0200
@@ -41,7 +41,8 @@
     def readfast(self, node):
         '''use the faster of readdelta or read'''
         r = self.rev(node)
-        if self.deltaparent(r) in self.parentrevs(r):
+        deltaparent = self.deltaparent(r)
+        if deltaparent != revlog.nullrev and deltaparent in self.parentrevs(r):
             return self.readdelta(node)
         return self.read(node)
 
--- a/mercurial/revlog.py	Thu May 05 11:33:02 2011 -0400
+++ b/mercurial/revlog.py	Thu May 05 18:05:24 2011 +0200
@@ -830,11 +830,14 @@
 
     def deltaparent(self, rev):
         """return deltaparent of the given revision"""
-        return rev - 1
+        if self.index[rev][3] == rev:
+            return nullrev
+        else:
+            return rev - 1
 
     def revdiff(self, rev1, rev2):
         """return or calculate a delta between two revisions"""
-        if self.base(rev2) != rev2 and self.deltaparent(rev2) == rev1:
+        if rev1 != nullrev and self.deltaparent(rev2) == rev1:
             return self._chunk(rev2)
 
         return mdiff.textdiff(self.revision(self.node(rev1)),