# HG changeset patch # User Pierre-Yves David # Date 1490343530 -3600 # Node ID 83e6933ae00efdefd70930c51db2fa7190beaa83 # Parent 81f5ebd9e9d0ba86acc4fcb09bf5b66c217a9bb5 subranges: add a utility function to access the cache This is preparing on disk persistence for the value in this cache. diff -r 81f5ebd9e9d0 -r 83e6933ae00e hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Fri Mar 24 09:15:18 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 09:18:50 2017 +0100 @@ -215,9 +215,9 @@ seen += 1 original.remove(value) # might have been added from other source __, rangeid = value - if self._subrangescache.get(rangeid) is None: + if self._getsub(rangeid) is None: for sub in self.subranges(repo, rangeid): - if self._subrangescache.get(sub) is None: + if self._getsub(sub) is None: heappush(rangeheap, (-sub[0], sub)) ui.progress(_("filling stablerange cache"), None, total=nbrevs) @@ -260,7 +260,7 @@ return self.depthrev(repo, headrev) - index def subranges(self, repo, rangeid): - cached = self._subrangescache.get(rangeid) + cached = self._getsub(rangeid) if cached is not None: return cached value = self._subranges(repo, rangeid) @@ -310,6 +310,12 @@ This mostly exist to help the on disk persistence.""" self._depthcache[rev] = value + def _getsub(self, rev): + """utility function used to access the subranges cache + + This mostly exist to help the on disk persistence""" + return self._subrangescache.get(rev) + def _filestablesortcache(self, sortedrevs, merge): if merge not in self._stablesortprepared: self._stablesortprepared[merge] = (sortedrevs, len(sortedrevs)) @@ -457,7 +463,7 @@ reurange = (reusablerev, rangeid[1]) # if we have an entry for the current range, lets update the cache # if we already have subrange for this range, no need to prepare it. - if self._subrangescache.get(reurange) is not None: + if self._getsub(reurange) is not None: return None # look like we found a relevent parentrange with no cache yet