# HG changeset patch # User David Soria Parra # Date 2017-11-23 22:12:55 # Node ID ec25c8275cfaac673ccb9e1ac22d0c554b9fe672 # Parent fd8b6b183073da2822f21e01b7914caa7ba59131 hbisect: use a revset for ancestor calculation Since we have revsets we can be more concise in doing the ancestor calulcation. Significant commits are all descendent of the topmost good commits. Test Plan: python run-tests.py test-bisect* Differential Revision: https://phab.mercurial-scm.org/D1498 diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -37,29 +37,10 @@ def bisect(repo, state): skip = set([changelog.rev(n) for n in state['skip']]) def buildancestors(bad, good): - # only the earliest bad revision matters badrev = min([changelog.rev(n) for n in bad]) - goodrevs = [changelog.rev(n) for n in good] - goodrev = min(goodrevs) - # build visit array - ancestors = [None] * (len(changelog) + 1) # an extra for [-1] - - # set nodes descended from goodrevs - for rev in goodrevs: + ancestors = [None] * (len(changelog) + 1) + for rev in repo.revs("descendants(%ln) - ancestors(%ln)", good, good): ancestors[rev] = [] - for rev in changelog.revs(goodrev + 1): - for prev in clparents(rev): - if ancestors[prev] == []: - ancestors[rev] = [] - - # clear good revs from array - for rev in goodrevs: - ancestors[rev] = None - for rev in changelog.revs(len(changelog), goodrev): - if ancestors[rev] is None: - for prev in clparents(rev): - ancestors[prev] = None - if ancestors[badrev] is None: return badrev, None return badrev, ancestors