Patchwork D1498: hbisect: use a revset for ancestor calculation

login
register
mail settings
Submitter phabricator
Date Nov. 23, 2017, 10:24 p.m.
Message ID <differential-rev-PHID-DREV-c5tqkfeqbhmjqc2ocsm7-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25730/
State Superseded
Headers show

Comments

phabricator - Nov. 23, 2017, 10:24 p.m.
dsp created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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*

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1498

AFFECTED FILES
  mercurial/hbisect.py

CHANGE DETAILS




To: dsp, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -37,29 +37,10 @@ 
     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