Mercurial > public > mercurial-scm > hg
comparison mercurial/hbisect.py @ 6858:8f256bf98219
Add support for multiple possible bisect results (issue1228, issue1182)
The real reason for both issue is that bisect can not handle cases where there
are multiple possibilities for the result.
Example (from issue1228):
rev 0 -> good
rev 1 -> skipped
rev 2 -> skipped
rev 3 -> skipped
rev 4 -> bad
Note that this patch does not only fix the reported Assertion Error but also
the problem of a non converging bisect:
hg init
for i in `seq 3`; do echo $i > $i; hg add $i; hg ci -m$i; done
hg bisect -b 2
hg bisect -g 0
hg bisect -s
From this state on, you can:
a) mark as bad forever (non converging!)
b) mark as good to get an inconsistent state
c) skip for the Assertion Error
Minor description and code edits by pmezard.
author | Bernhard Leiner <bleiner@gmail.com> |
---|---|
date | Sat, 02 Aug 2008 22:10:10 +0200 |
parents | fe8dbbe9520d |
children | 0b6f2fa5e03f |
comparison
equal
deleted
inserted
replaced
6856:c6890cfc2253 | 6858:8f256bf98219 |
---|---|
10 from i18n import _ | 10 from i18n import _ |
11 from node import short | 11 from node import short |
12 import util | 12 import util |
13 | 13 |
14 def bisect(changelog, state): | 14 def bisect(changelog, state): |
15 """find the next node (if any) for testing during a bisect search. | |
16 returns a (nodes, number, good) tuple. | |
17 | |
18 'nodes' is the final result of the bisect if 'number' is 0. | |
19 Otherwise 'number' indicates the remaining possible candidates for | |
20 the search and 'nodes' contains the next bisect target. | |
21 'good' is True if bisect is searching for a first good changeset, False | |
22 if searching for a first bad one. | |
23 """ | |
24 | |
15 clparents = changelog.parentrevs | 25 clparents = changelog.parentrevs |
16 skip = dict.fromkeys([changelog.rev(n) for n in state['skip']]) | 26 skip = dict.fromkeys([changelog.rev(n) for n in state['skip']]) |
17 | 27 |
18 def buildancestors(bad, good): | 28 def buildancestors(bad, good): |
19 # only the earliest bad revision matters | 29 # only the earliest bad revision matters |
60 children[prev] = [rev] | 70 children[prev] = [rev] |
61 visit.append(prev) | 71 visit.append(prev) |
62 | 72 |
63 candidates.sort() | 73 candidates.sort() |
64 # have we narrowed it down to one entry? | 74 # have we narrowed it down to one entry? |
75 # or have all other possible candidates besides 'bad' have been skipped? | |
65 tot = len(candidates) | 76 tot = len(candidates) |
66 if tot == 1: | 77 unskipped = [c for c in candidates if (c not in skip) and (c != badrev)] |
67 return (bad, 0, good) | 78 if tot == 1 or not unskipped: |
79 return ([changelog.node(rev) for rev in candidates], 0, good) | |
68 perfect = tot / 2 | 80 perfect = tot / 2 |
69 | 81 |
70 # find the best node to test | 82 # find the best node to test |
71 best_rev = None | 83 best_rev = None |
72 best_len = -1 | 84 best_len = -1 |
101 ancestors[c] = a + [c] | 113 ancestors[c] = a + [c] |
102 | 114 |
103 assert best_rev is not None | 115 assert best_rev is not None |
104 best_node = changelog.node(best_rev) | 116 best_node = changelog.node(best_rev) |
105 | 117 |
106 return (best_node, tot, good) | 118 return ([best_node], tot, good) |