# HG changeset patch # User Benoit Boissinot # Date 2010-08-19 22:17:50 # Node ID ff84cd2bdfaf894760d7adb2b58c57c5cc8838f6 # Parent 9bce7ed50c9ac04c040be3077d793c80d85d0c9a 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). diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1056,26 +1056,30 @@ class revlog(object): 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 @@ class revlog(object): # 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)