stablerange: remove call to 'repo.revs'
It turned out that the percentage of time spend parsing the revset string was
two digits, so we compute de heads inline.
--- a/hgext3rd/evolve/obsdiscovery.py Sun Mar 12 08:38:39 2017 -0700
+++ b/hgext3rd/evolve/obsdiscovery.py Sat Mar 11 14:46:27 2017 -0800
@@ -557,15 +557,28 @@
cl = self._repo.changelog
+ result = []
bottom = self._revs[:localindex]
- top = self._revs[localindex:]
- bheads = self._repo.revs('heads(%ld)', bottom)
- result = []
+ top = _range(self._repo, self.head, globalindex, self._revs[localindex:])
+ #
+ toprootdepth = utility.depth(self._repo, top._revs[0])
+ if toprootdepth + len(top) == self.depth + 1:
+ bheads = [bottom[-1]]
+ else:
+ bheads = set(bottom)
+ parentrevs = cl.parentrevs
+ du = bheads.difference_update
+ for r in bottom:
+ du(parentrevs(r))
+ # if len(bheads) == 1:
+ # assert 1 == len(self._repo.revs('roots(%ld)', top._revs))
if len(bheads) == 1:
newhead = bottom[-1]
- newstart = utility.depth(self._repo, newhead) - len(bottom)
+ bottomdepth = utility.depth(self._repo, newhead)
+ newstart = bottomdepth - len(bottom)
result.append(_range(self._repo, newhead, newstart, bottom))
else:
+ # assert 1 < len(bheads), (toprootdepth, len(top), len(self))
cl = self._repo.changelog
for h in bheads:
subset = cl.ancestors([h], inclusive=True)
@@ -573,7 +586,7 @@
start = utility.depth(self._repo, h) - len(hrevs)
entry = _range(self._repo, h, start, [r for r in bottom if r in subset])
result.append(entry)
- result.append(_range(self._repo, self.head, globalindex, top))
+ result.append(top)
return result
def subranges(self):