# HG changeset patch # User Pierre-Yves David # Date 1489898032 -3600 # Node ID 086a85c37e9ea97f9b7a580af90b3f436ca25002 # Parent 8f63f4b1c33efccb8d99c6e41b63d93c2ce29515 stablerange: compute subranges from parent when possible Unless we are a merge, we can infer the standard subranges of a range by reusing the subranger of its parent. We update the implementation to do so. We still needs the "old way" for merge. We move that code in a dedicated function for the sake of simplicity. diff -r 8f63f4b1c33e -r 086a85c37e9e hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Wed Mar 22 04:27:42 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Sun Mar 19 05:33:52 2017 +0100 @@ -255,8 +255,33 @@ return slicepoint def _slicesrangeat(self, repo, rangeid, globalindex): + p1, p2 = repo.changelog.parentrevs(rangeid.head) + if p2 != nodemod.nullrev: + return self._slicesrangeatmerge(repo, rangeid, globalindex) + assert p1 != nodemod.nullrev + rangedepth = self.depthrev(repo, rangeid.head) + topsize = rangedepth - globalindex + + parentrange = stablerange(repo, p1, rangeid.index, rangeid._revs[:-1]) + if topsize == 1: + top = stablerange(repo, rangeid.head, globalindex, [rangeid.head]) + return [parentrange, top] + else: + # XXX recursive call, python have issue with them + # The best way to break it would be directly 'self.subranges' + # In that other method we could make sure subrangess for + # (p1(rev), idx) are available before slicing (rev, idx). But the + # heavy object approach makes it a bit inconvenient so that will + # wait for that heavy object to be gone. + parentsubranges = self.subranges(repo, parentrange) + slices = parentsubranges[:-1] # pop the top + top = stablerange(repo, rangeid.head, globalindex, rangeid._revs[-topsize:]) + slices.append(top) + return slices + + @staticmethod + def _slicesrangeatmerge(repo, rangeid, globalindex): localindex = globalindex - rangeid.index - cl = repo.changelog result = []