# HG changeset patch # User Pierre-Yves David # Date 1513807711 -3600 # Node ID db8feb4047927abbfed7d763ea62d84835faea81 # Parent 96d1cf475c198213bafad94b24eb8531539aa16d stablesort: abstract all cache access This prepare an on disk version of the cache diff -r 96d1cf475c19 -r db8feb404792 hgext3rd/evolve/stablesort.py --- a/hgext3rd/evolve/stablesort.py Mon Dec 18 20:04:50 2017 +0100 +++ b/hgext3rd/evolve/stablesort.py Wed Dec 20 23:08:31 2017 +0100 @@ -330,10 +330,10 @@ return result def getjumps(self, repo, rev): - if rev not in self._jumps: + if not self._hasjumpsdata(rev): parents = repo.changelog.parentrevs(rev) if parents[1] == nodemod.nullrev: - self._jumps[rev] = None + self._setjumps(rev, None) else: # merge ! warn the cache tiebreaker = _mergepoint_tie_breaker(repo) @@ -341,7 +341,16 @@ for r in self.walkfrom(repo, rev): if r == minparent: break - return self._jumps[rev] + return self._getjumps(rev) + + def _hasjumpsdata(self, rev): + return rev in self._jumps + + def _getjumps(self, rev): + return self._jumps.get(rev) + + def _setjumps(self, rev, jumps): + self._jumps[rev] = jumps def walkfrom(self, repo, head): tiebreaker = _mergepoint_tie_breaker(repo) @@ -374,7 +383,7 @@ previous_current_1 = current assert previous_current_1 is not previous_current_2 - jumps = self._jumps.get(current) + jumps = self._getjumps(current) if jumps is not None: # we have enough cached information to directly iterate over # the exclusive size. @@ -416,7 +425,7 @@ if rev == current: recordjump(rev, lower_parent, 1) - self._jumps[current] = jumps + self._setjumps(current, jumps) current = lower_parent