diff mercurial/revlog.py @ 23254:d23834b871ac

debugrevlog: fix computing chain length in debugrevlog -d The chain length was computed correctly only when generaldelta feature was enabled. Now it's fixed. When generaldelta is disabled the base revision in revlog index is not the revision we have delta against - it's always previous revision. Instead of incorrect chainbaseandlen in command.py we are now using two single-responsibility functions in revlog.py: - chainbase(rev) - chainlen(rev) Only chainlen(rev) was missing so it was written to mimic the way the chain of deltas is actually found during file reconstruction.
author Mateusz Kwapich <mitrandir@fb.com>
date Thu, 06 Nov 2014 14:08:25 -0800
parents 8a096d4d0862
children 76effa770ff9
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Nov 05 10:13:01 2014 +0000
+++ b/mercurial/revlog.py	Thu Nov 06 14:08:25 2014 -0800
@@ -350,6 +350,20 @@
             rev = base
             base = index[rev][3]
         return base
+    def chainlen(self, rev):
+        index = self.index
+        generaldelta = self._generaldelta
+        iterrev = rev
+        e = index[iterrev]
+        clen = 0
+        while iterrev != e[3]:
+            clen += 1
+            if generaldelta:
+                iterrev = e[3]
+            else:
+                iterrev -= 1
+            e = index[iterrev]
+        return clen
     def flags(self, rev):
         return self.index[rev][0] & 0xFFFF
     def rawsize(self, rev):