Mercurial > hg
changeset 40052:55db747a21ad
revlog: rename _cache to _revisioncache
"cache" is generic and revlog instances have multiple caches. Let's
be descriptive about what this is a cache for.
Differential Revision: https://phab.mercurial-scm.org/D4866
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 03 Oct 2018 10:32:21 -0700 |
parents | cdf61ab1f54c |
children | 8c692a6b5ad1 |
files | mercurial/bundlerepo.py mercurial/revlog.py mercurial/unionrepo.py |
diffstat | 3 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Wed Oct 03 10:56:48 2018 -0700 +++ b/mercurial/bundlerepo.py Wed Oct 03 10:32:21 2018 -0700 @@ -127,8 +127,8 @@ iterrev = rev # reconstruct the revision if it is from a changegroup while iterrev > self.repotiprev: - if self._cache and self._cache[1] == iterrev: - rawtext = self._cache[2] + if self._revisioncache and self._revisioncache[1] == iterrev: + rawtext = self._revisioncache[2] break chain.append(iterrev) iterrev = self.index[iterrev][3] @@ -143,7 +143,7 @@ 'read', raw=raw) if validatehash: self.checkhash(text, node, rev=rev) - self._cache = (node, rev, rawtext) + self._revisioncache = (node, rev, rawtext) return text def baserevision(self, nodeorrev):
--- a/mercurial/revlog.py Wed Oct 03 10:56:48 2018 -0700 +++ b/mercurial/revlog.py Wed Oct 03 10:32:21 2018 -0700 @@ -346,7 +346,7 @@ self._checkambig = checkambig self._censorable = censorable # 3-tuple of (node, rev, text) for a raw revision. - self._cache = None + self._revisioncache = None # Maps rev to chain base rev. self._chainbasecache = util.lrucachedict(100) # 2-tuple of (offset, data) of raw data from the revlog at an offset. @@ -545,7 +545,7 @@ return True def clearcaches(self): - self._cache = None + self._revisioncache = None self._chainbasecache.clear() self._chunkcache = (0, '') self._pcache = {} @@ -1524,11 +1524,11 @@ rawtext = None if node == nullid: return "" - if self._cache: - if self._cache[0] == node: + if self._revisioncache: + if self._revisioncache[0] == node: # _cache only stores rawtext if raw: - return self._cache[2] + return self._revisioncache[2] # duplicated, but good for perf if rev is None: rev = self.rev(node) @@ -1536,11 +1536,11 @@ flags = self.flags(rev) # no extra flags set, no flag processor runs, text = rawtext if flags == REVIDX_DEFAULT_FLAGS: - return self._cache[2] + return self._revisioncache[2] # rawtext is reusable. need to run flag processor - rawtext = self._cache[2] + rawtext = self._revisioncache[2] - cachedrev = self._cache[1] + cachedrev = self._revisioncache[1] # look up what we need to read if rawtext is None: @@ -1549,10 +1549,10 @@ chain, stopped = self._deltachain(rev, stoprev=cachedrev) if stopped: - rawtext = self._cache[2] + rawtext = self._revisioncache[2] # drop cache to save memory - self._cache = None + self._revisioncache = None targetsize = None rawsize = self.index[rev][2] @@ -1565,7 +1565,7 @@ bins = bins[1:] rawtext = mdiff.patches(rawtext, bins) - self._cache = (node, rev, rawtext) + self._revisioncache = (node, rev, rawtext) if flags is None: if rev is None: @@ -1926,7 +1926,7 @@ rawtext = deltacomputer.buildtext(revinfo, fh) if type(rawtext) == bytes: # only accept immutable objects - self._cache = (node, curr, rawtext) + self._revisioncache = (node, curr, rawtext) self._chainbasecache[curr] = deltainfo.chainbase return node @@ -2132,7 +2132,7 @@ transaction.add(self.indexfile, end) # then reset internal state in memory to forget those revisions - self._cache = None + self._revisioncache = None self._chaininfocache = {} self._chunkclear() for x in pycompat.xrange(rev, len(self)):
--- a/mercurial/unionrepo.py Wed Oct 03 10:56:48 2018 -0700 +++ b/mercurial/unionrepo.py Wed Oct 03 10:32:21 2018 -0700 @@ -110,7 +110,7 @@ if rev > self.repotiprev: text = self.revlog2.revision(node) - self._cache = (node, rev, text) + self._revisioncache = (node, rev, text) else: text = self.baserevision(rev) # already cached