changeset 8318:6b8513f8274a

revlog: add cache priming for reconstructing delta chains
author Matt Mackall <mpm@selenic.com>
date Thu, 07 May 2009 19:39:45 -0500
parents 5cdf4067857a
children b7017097a4ec
files mercurial/revlog.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Thu May 07 19:39:45 2009 -0500
+++ b/mercurial/revlog.py	Thu May 07 19:39:45 2009 -0500
@@ -949,6 +949,14 @@
 
         return self._loadchunk(offset, length, df)
 
+    def _prime(self, startrev, endrev, df):
+        start = self.start(startrev)
+        end = self.end(endrev)
+        if self._inline:
+            start += (startrev + 1) * self._io.size
+            end += (startrev + 1) * self._io.size
+        self._loadchunk(start, end - start, df)
+
     def chunk(self, rev, df=None):
         start, length = self.start(rev), self.length(rev)
         if self._inline:
@@ -989,10 +997,12 @@
             self._loadindex(base, rev + 1)
             if not self._inline and rev > base + 1:
                 df = self.opener(self.datafile)
+                self._prime(base, rev, df)
         else:
             self._loadindex(base, rev + 1)
             if not self._inline and rev > base:
                 df = self.opener(self.datafile)
+                self._prime(base, rev, df)
             text = self.chunk(base, df=df)
 
         bins = [self.chunk(r, df) for r in xrange(base + 1, rev + 1)]