# HG changeset patch # User Siddharth Agarwal # Date 1378533911 25200 # Node ID e17976978ee46fe45aaa78a728f5a9231a68e9ee # Parent 1aab406be57c4a4bbe55dab1a6a49991956d2863 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. diff -r 1aab406be57c -r e17976978ee4 mercurial/revlog.py --- 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)