revlog: compute length of compressed deltas along with chain length
authorSiddharth Agarwal <sid0@fb.com>
Tue, 11 Nov 2014 19:54:36 -0800
changeset 23286 40e0067899d4
parent 23285 6cc1f388ac80
child 23287 426d7f901789
revlog: compute length of compressed deltas along with chain length In upcoming patches to the revlog, we're going to split up the notions of bounding I/O and bounding CPU.
mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Nov 11 21:41:12 2014 -0800
+++ b/mercurial/revlog.py	Tue Nov 11 19:54:36 2014 -0800
@@ -354,19 +354,25 @@
             base = index[rev][3]
         return base
     def chainlen(self, rev):
+        return self._chaininfo(rev)[0]
+    def _chaininfo(self, rev):
         index = self.index
         generaldelta = self._generaldelta
         iterrev = rev
         e = index[iterrev]
         clen = 0
+        compresseddeltalen = 0
         while iterrev != e[3]:
             clen += 1
+            compresseddeltalen += e[1]
             if generaldelta:
                 iterrev = e[3]
             else:
                 iterrev -= 1
             e = index[iterrev]
-        return clen
+        # add text length of base since decompressing that also takes work
+        compresseddeltalen += e[1]
+        return clen, compresseddeltalen
     def flags(self, rev):
         return self.index[rev][0] & 0xFFFF
     def rawsize(self, rev):