changeset 19716:e17976978ee4

revlog: move chunk cache preload from revision to _chunks In case we don't have a cached text already, add the base rev to the list passed to _chunks. In the cached case this also avoids unnecessarily preloading the chunk for the cached rev.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 06 Sep 2013 23:05:11 -0700
parents 1aab406be57c
children 6031fe568cd0
files mercurial/revlog.py
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Sep 06 22:57:51 2013 -0700
+++ b/mercurial/revlog.py	Fri Sep 06 23:05:11 2013 -0700
@@ -859,6 +859,8 @@
         '''faster version of [self._chunk(rev) for rev in revs]
 
         Assumes that revs is in ascending order.'''
+        if not revs:
+            return []
         start = self.start
         length = self.length
         inline = self._inline
@@ -868,7 +870,8 @@
         l = []
         ladd = l.append
 
-        # XXX assume for now that chunkcache is preloaded
+        # preload the cache
+        self._chunkraw(revs[0], revs[-1])
         offset, data = self._chunkcache
 
         for rev in revs:
@@ -946,21 +949,22 @@
             else:
                 iterrev -= 1
             e = index[iterrev]
-        chain.reverse()
-        base = iterrev
 
         if iterrev == cachedrev:
             # cache hit
             text = self._cache[2]
+        else:
+            chain.append(iterrev)
+        chain.reverse()
 
         # drop cache to save memory
         self._cache = None
 
-        self._chunkraw(base, rev)
+        bins = self._chunks(chain)
         if text is None:
-            text = str(self._chunkbase(base))
+            text = str(bins[0])
+            bins = bins[1:]
 
-        bins = self._chunks(chain)
         text = mdiff.patches(text, bins)
 
         text = self._checkhash(text, node, rev)