Mercurial > evolve
changeset 2132:d77262807411
stablerange: move standard slice point definition in main class
More migration of code away from the doomed individual class.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sun, 19 Mar 2017 04:43:33 +0100 |
parents | 86dd39478638 |
children | 323480863248 |
files | hgext3rd/evolve/stablerange.py |
diffstat | 1 files changed, 17 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/stablerange.py Sun Mar 19 04:39:00 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Sun Mar 19 04:43:33 2017 +0100 @@ -236,6 +236,22 @@ # this class reach. return self._subrangescache.get(rangeid) + def _slicepoint(self, repo, rangeid): + rangedepth = self.depthrev(repo, rangeid.head) + step = _hlp2(rangedepth) + standard_start = 0 + while standard_start < rangeid.index and 0 < step: + if standard_start + step < rangedepth: + standard_start += step + step //= 2 + if rangeid.index == standard_start: + slicesize = _hlp2(len(rangeid)) + slicepoint = rangeid.index + slicesize + else: + assert standard_start < rangedepth + slicepoint = standard_start + return slicepoint + def _slicesrangeat(self, repo, rangeid, globalindex): localindex = globalindex - rangeid.index @@ -329,18 +345,7 @@ cached = cache.subranges(self._repo, self) if cached is not None: return cached - step = _hlp2(self.depth) - standard_start = 0 - while standard_start < self.index and 0 < step: - if standard_start + step < self.depth: - standard_start += step - step //= 2 - if self.index == standard_start: - slicesize = _hlp2(len(self)) - slicepoint = self.index + slicesize - else: - assert standard_start < self.depth - slicepoint = standard_start + slicepoint = cache._slicepoint(self._repo, self) result = cache._slicesrangeat(self._repo, self, slicepoint) self._repo.stablerange.setsubranges(self, result) return result