stablerange: fix slicing of arbitrary ranges
Pull bundle trigger slicing from range with arbitrary initial skip. We have to
adjust the current slicing to take this into account.
--- a/hgext3rd/evolve/stablerange.py Mon Sep 24 01:16:00 2018 +0200
+++ b/hgext3rd/evolve/stablerange.py Tue Sep 25 12:19:41 2018 +0200
@@ -390,6 +390,12 @@
# find were we need to slice
slicepoint = self._slicepoint(repo, rangeid)
+ ret = self._slicesrangeat(repo, rangeid, slicepoint)
+
+ return ret
+
+ def _slicesrangeat(self, repo, rangeid, slicepoint):
+ headrev, initial_index = rangeid
self._warmcachefor(repo, rangeid, slicepoint)
stable_parent_data = self._parentrange(repo, rangeid)
@@ -411,7 +417,13 @@
# The parent is above the slice point,
# it's lower subrange will be the same so we just get them,
# (and the top range is always the same)
- subranges = self.subranges(repo, stable_parent_range)[:-1]
+ subranges = self.subranges(repo, stable_parent_range)[:]
+ parenttop = subranges.pop()
+ if (stable_parent_depth - slicepoint) < self.rangelength(repo, parenttop):
+ # possible case when we reduce an arbitrary range to its
+ # canonical parts
+ midranges = self._slicesrangeat(repo, parenttop, slicepoint)
+ subranges.extend(midranges[:-1])
subranges.append(top_range)
elif initial_index < stable_parent_depth < slicepoint:
# the parent is below the range we are considering, we need to
@@ -428,6 +440,13 @@
slicepoint))
subranges.append(top_range)
+ ### slow code block to validated the slicing works as expected
+ # toprevs = self.revsfromrange(repo, rangeid)
+ # subrevs = []
+ # for s in subranges:
+ # subrevs.extend(self.revsfromrange(repo, s))
+ # assert toprevs == subrevs, (rangeid, slicepoint, stable_parent_range, stable_parent_depth, toprevs, subrevs)
+
return subranges
def _unique_subranges(self, repo, headrev, initial_index, slicepoint):
--- a/hgext3rd/evolve/stablerangecache.py Mon Sep 24 01:16:00 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py Tue Sep 25 12:19:41 2018 +0200
@@ -388,7 +388,7 @@
class mergepointsql(stablerangesql, stablerange.stablerange_mergepoint):
- _schemaversion = 2
+ _schemaversion = 3
_cachefile = 'cache/evoext_stablerange_v2.sqlite'
_cachename = 'evo-ext-stablerange-mergepoint'