comparison mercurial/hbisect.py @ 35129:ec25c8275cfa

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
author David Soria Parra <davidsp@fb.com>
date Thu, 23 Nov 2017 14:12:55 -0800
parents fd8b6b183073
children 8287df8b7be5
comparison
equal deleted inserted replaced
35128:fd8b6b183073 35129:ec25c8275cfa
35 changelog = repo.changelog 35 changelog = repo.changelog
36 clparents = changelog.parentrevs 36 clparents = changelog.parentrevs
37 skip = set([changelog.rev(n) for n in state['skip']]) 37 skip = set([changelog.rev(n) for n in state['skip']])
38 38
39 def buildancestors(bad, good): 39 def buildancestors(bad, good):
40 # only the earliest bad revision matters
41 badrev = min([changelog.rev(n) for n in bad]) 40 badrev = min([changelog.rev(n) for n in bad])
42 goodrevs = [changelog.rev(n) for n in good] 41 ancestors = [None] * (len(changelog) + 1)
43 goodrev = min(goodrevs) 42 for rev in repo.revs("descendants(%ln) - ancestors(%ln)", good, good):
44 # build visit array
45 ancestors = [None] * (len(changelog) + 1) # an extra for [-1]
46
47 # set nodes descended from goodrevs
48 for rev in goodrevs:
49 ancestors[rev] = [] 43 ancestors[rev] = []
50 for rev in changelog.revs(goodrev + 1):
51 for prev in clparents(rev):
52 if ancestors[prev] == []:
53 ancestors[rev] = []
54
55 # clear good revs from array
56 for rev in goodrevs:
57 ancestors[rev] = None
58 for rev in changelog.revs(len(changelog), goodrev):
59 if ancestors[rev] is None:
60 for prev in clparents(rev):
61 ancestors[prev] = None
62
63 if ancestors[badrev] is None: 44 if ancestors[badrev] is None:
64 return badrev, None 45 return badrev, None
65 return badrev, ancestors 46 return badrev, ancestors
66 47
67 good = False 48 good = False