# HG changeset patch # User Pierre-Yves David # Date 1490331080 -3600 # Node ID 6d9cadc635d54f942444a6d9e3b0460a656d822a # Parent 14e876c5e1c3d9d260fd663bde2b8aa0a09fc62e merge-slicing: simplify various aspect of the code Especially the case were the bottom have single heads is not more efficiently handled. diff -r 14e876c5e1c3 -r 6d9cadc635d5 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Thu Mar 23 14:17:15 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 05:51:20 2017 +0100 @@ -418,12 +418,11 @@ result = [] allrevs = self.revsfromrange(repo, rangeid) bottomrevs = allrevs[:localindex] - top = (rangeid[0], globalindex) - # - rangedepth = self.depthrev(repo, rangeid[0]) - maxbottomdepth = self.depthrev(repo, bottomrevs[-1]) - if maxbottomdepth + self.rangelength(repo, top) == rangedepth: - bheads = [bottomrevs[-1]] + + if globalindex == self.depthrev(repo, bottomrevs[-1]): + # simple case, top revision in the bottom set contains exactly the + # revision we needs + result.append((bottomrevs[-1], rangeid[1])) else: bheads = set(bottomrevs) parentrevs = cl.parentrevs @@ -431,23 +430,14 @@ du = bheads.difference_update for r in bottomrevs: du(parents(r, parentrevs)) - # if len(bheads) == 1: - # assert 1 == len(repo.revs('roots(%ld)', top._revs)) - if len(bheads) == 1: - newhead = bottomrevs[-1] - bottomdepth = self.depthrev(repo, newhead) - newstart = bottomdepth - len(bottomrevs) - bottom = (newhead, newstart) - result.append(bottom) - else: - # assert 1 < len(bheads), (toprootdepth, len(top), len(rangeid)) - cl = repo.changelog for h in bheads: subset = cl.ancestors([h], inclusive=True) hrevs = [r for r in bottomrevs if r in subset] start = self.depthrev(repo, h) - len(hrevs) entry = (h, start) result.append(entry) + # top part is trivial + top = (rangeid[0], globalindex) result.append(top) return result