stablerange: move the subrange cache into our new class
This is the first step toward having more logic in that class
--- a/hgext3rd/evolve/obsdiscovery.py Sun Mar 19 00:44:31 2017 +0100
+++ b/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 03:47:28 2017 +0100
@@ -601,9 +601,7 @@
return result
def subranges(self):
- if not util.safehasattr(self._repo, '_subrangecache'):
- self._repo._subrangecache = {}
- cached = self._repo._subrangecache.get(self)
+ cached = self._repo.stablerange.subranges(self._repo, self)
if cached is not None:
return cached
if len(self) == 1:
@@ -621,7 +619,7 @@
assert standard_start < self.depth
slicepoint = standard_start
result = self._slicesat(slicepoint)
- self._repo._subrangecache[self] = result
+ self._repo.stablerange.setsubranges(self, result)
return result
@util.propertycache
--- a/hgext3rd/evolve/stablerange.py Sun Mar 19 00:44:31 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 03:47:28 2017 +0100
@@ -22,6 +22,7 @@
def __init__(self):
self._depthcache = {}
+ self._subrangescache = {}
def depthrev(self, repo, rev):
repo = repo.unfiltered()
@@ -102,6 +103,16 @@
revdepth += len(cl.findmissingrevs(common=[anc], heads=[rev]))
return revdepth
+ def subranges(self, repo, rangeid):
+ cached = self._subrangescache.get(rangeid)
+ if cached is not None:
+ return cached
+
+ def setsubranges(self, rangeid, value):
+ # XXX temporary cache setter as value computation are performed outside
+ # this class reach.
+ return self._subrangescache.get(rangeid)
+
@eh.reposetup
def setupcache(ui, repo):