# HG changeset patch # User Pierre-Yves David # Date 1490340670 -3600 # Node ID d83bf47734332232d2ad4e8e84e7b95f64757673 # Parent 9e30934d4487b16fd58e98fec4dbbd38aab2a6ad stablerange: rearrange the code picking subrange to warm Same logic, as the previous changesets, we prepare the code before adding merge support. diff -r 9e30934d4487 -r d83bf4773433 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Fri Mar 24 08:20:36 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 08:31:10 2017 +0100 @@ -342,7 +342,7 @@ stack = [] current = rangeid while current is not None: - current = self._unpreparedparentrange(repo, current, slicepoint) + current = self._cold_reusable(repo, current, slicepoint) if current is not None: stack.append(current) while stack: @@ -350,7 +350,7 @@ self.subranges(repo, stack.pop()) return self._slicesrangeat(repo, rangeid, slicepoint) - def _unpreparedparentrange(self, repo, rangeid, slicepoint): + def _cold_reusable(self, repo, rangeid, slicepoint): """return parent range that it would be useful to prepare to slice rangeid at slicepoint @@ -360,16 +360,19 @@ p1, p2 = self._parents(rangeid[0], repo.changelog.parentrevs) if p2 != nodemod.nullrev: return None - parentrange = (p1, rangeid[1]) + reusablerev = p1 + # if we reached the slicepoint, no need to go further + if self.depthrev(repo, reusablerev) <= slicepoint: + return None + + reurange = (reusablerev, rangeid[1]) # if we have an entry for the current range, lets update the cache # if we already have subrange for this range, no need to prepare it. - if self._subrangescache.get(parentrange) is not None: + if self._subrangescache.get(reurange) is not None: return None - # if we reached the slicepoint, no need to go further - if self.depthrev(repo, parentrange[0]) == slicepoint: - return None + # look like we found a relevent parentrange with no cache yet - return parentrange + return reurange def _slicepoint(self, repo, rangeid): rangedepth = self.depthrev(repo, rangeid[0])