# HG changeset patch # User Pierre-Yves David # Date 1490260799 -3600 # Node ID 61a8b51348a1553c0aa0a41a1a947b08feadb8d9 # Parent 8a2e1f6e54432d24d430a3415e4def8cbe2275ed 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. diff -r 8a2e1f6e5443 -r 61a8b51348a1 hgext3rd/evolve/stablerange.py --- 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)