revlog.revision(): minor cleanup
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 20 Aug 2010 00:17:50 +0200
changeset 11995 ff84cd2bdfaf
parent 11993 9bce7ed50c9a
child 11996 3195cf01dfb9
revlog.revision(): minor cleanup Rename some variables, making the name more obvious (in particular "cache" was actually two different variable. Move code around, moving the index preloading before the deltachain computation, without that index preloading was useless (everything was read in deltachain).
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu Aug 19 23:13:20 2010 +0200
+++ b/mercurial/revlog.py	Fri Aug 20 00:17:50 2010 +0200
@@ -1056,26 +1056,30 @@
 
     def revision(self, node):
         """return an uncompressed revision of a given node"""
-        cache = nullrev
+        cachedrev = nullrev
         if node == nullid:
             return ""
         if self._cache:
-            cache = self._cache[1]
             if self._cache[0] == node:
                 return self._cache[2]
+            cachedrev = self._cache[1]
 
         # look up what we need to read
         text = None
         rev = self.rev(node)
-        cache, base, chain = self.deltachain(rev, cache)
+        base = self.base(rev)
 
         # check rev flags
         if self.flags(rev) & ~REVIDX_KNOWN_FLAGS:
             raise RevlogError(_('incompatible revision flag %x') %
                               (self.flags(rev) & ~REVIDX_KNOWN_FLAGS))
 
+        # build delta chain
+        self._loadindex(base, rev + 1)
+        cachehit, base, chain = self.deltachain(rev, cachedrev)
+
         # do we have useful data cached?
-        if cache and self._cache:
+        if cachehit and self._cache:
             global _cached
             _cached += 1
             text = self._cache[2]
@@ -1087,7 +1091,6 @@
         # drop cache to save memory
         self._cache = None
 
-        self._loadindex(base, rev + 1)
         self._chunkraw(base, rev)
         if text is None:
             text = self._chunk(base)