subranges: detach cache logic from computation logic
Having both the logic around cache checking and setting makes is a bit harder to
follow. In addition, this allow to gather the computation logic next to the
other related function.
--- a/hgext3rd/evolve/stablerange.py Thu Mar 23 10:07:21 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Thu Mar 23 10:19:59 2017 +0100
@@ -223,11 +223,7 @@
cached = self._subrangescache.get(rangeid)
if cached is not None:
return cached
- if self.rangelength(repo, rangeid) == 1:
- value = []
- else:
- slicepoint = self._slicepoint(repo, rangeid)
- value = self._slicesrangeat(repo, rangeid, slicepoint)
+ value = self._subranges(repo, rangeid)
self._subrangescache[rangeid] = value
return value
@@ -298,6 +294,12 @@
revdepth += len(cl.findmissingrevs(common=[anc], heads=[rev]))
return revdepth
+ def _subranges(self, repo, rangeid):
+ if self.rangelength(repo, rangeid) == 1:
+ return []
+ slicepoint = self._slicepoint(repo, rangeid)
+ return self._slicesrangeat(repo, rangeid, slicepoint)
+
def _slicepoint(self, repo, rangeid):
rangedepth = self.depthrev(repo, rangeid[0])
step = _hlp2(rangedepth)