# HG changeset patch # User Pierre-Yves David # Date 1512877695 -3600 # Node ID d942fc5847f972d44fc7623bdee779af450a5547 # Parent 318c938be80d9d40f595841bba5d00471a1b6531 stablesort: move parent range computation into its own method Now that we have running code, we'll need to avoid too deep recursion. We extract the piece dealing with the parent range before we write more code to warm it. diff -r 318c938be80d -r d942fc5847f9 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Sun Dec 10 03:58:22 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Sun Dec 10 04:48:15 2017 +0100 @@ -376,6 +376,12 @@ relevant_parent = min(p1, p2, key=tiebreaker) return relevant_parent + def _parentrange(self, repo, rangeid): + stable_parent = self._stableparent(repo, rangeid[0]) + stable_parent_depth = self.depthrev(repo, stable_parent) + stable_parent_range = (stable_parent, rangeid[1]) + return stable_parent_depth, stable_parent_range + def _subranges(self, repo, rangeid): headrev, initial_index = rangeid # size 1 range can't be sliced @@ -384,13 +390,12 @@ # find were we need to slice slicepoint = self._slicepoint(repo, rangeid) - stable_parent = self._stableparent(repo, headrev) - stable_parent_depth = self.depthrev(repo, stable_parent) - stable_parent_range = (stable_parent, initial_index) - # top range is always the same, so we can build it early for all top_range = (headrev, slicepoint) + stable_parent_data = self._parentrange(repo, rangeid) + stable_parent_depth, stable_parent_range = stable_parent_data + # now find out about the lower range, if we are lucky there is only # one, otherwise we need to issue multiple one to cover every revision # on the lower set. (and cover them only once).