changeset 23286:40e0067899d4

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.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 11 Nov 2014 19:54:36 -0800
parents 6cc1f388ac80
children 426d7f901789
files mercurial/revlog.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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):