How to automate hg bisect --extend to follow common ancestors?
mercurial
Solution
Bisect won't go outside the initial range of changesets. So if you initially set changeset 10 as good and changset 20 as bad, and after a few iterations cs 12 is found bad but is a merge with cs 5, bisect will stop. `--extend` is then used to expand the range outside the initial 10-20. If you want to search the entire range, set cs 0 as good and tip as bad and you should never need to use extend.
Consider the following history. Changeset 4 introduces a "bug".
@ 12:8ae1fff407c8:bad6
|
o 11:27edd4ba0a78:bad5
|
o 10:312ba3d6eb29:bad4
|\
| o 9:68ae20ea0c02:good33
| |
| o 8:916e977fa594:good32
| |
| o 7:b9d00094223f:good31
| |
o | 6:a7cab1800465:bad3
| |
o | 5:a84e45045a29:bad2
| |
o | 4:d0a381a67072:bad1
| |
o | 3:54349a6276cc:good4
|/
o 2:4588e394e325:good3
|
o 1:de79725cb39a:good2
|
o 0:2641cc78ce7a:good1
Now if I mark changeset 7 as good and tip as bad, then 10 as found as the first bad changeset, but it is a merge and suggests extending the search to changeset 2 (the common ancestor):
C:\data>hg bisect -r
C:\data>hg bisect -g 7
C:\data>hg bisect -b tip
Testing changeset 9:68ae20ea0c02 (5 changesets remaining, ~2 tests)
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
C:\data>hg bisect -c check.bat
Changeset 9:68ae20ea0c02: good
Changeset 10:312ba3d6eb29: bad
The first bad revision is:
changeset: 10:312ba3d6eb29
parent: 9:68ae20ea0c02
parent: 6:a7cab1800465
summary: bad4
Not all ancestors of this changeset have been checked.
Use bisect --extend to continue the bisection from
the common ancestor, 4588e394e325.
But if I set changeset 0 as good and tip as bad, it finds the right changeset without extend:
C:\data>hg bisect -g 0
C:\data>hg bisect -b tip
Testing changeset 6:a7cab1800465 (12 changesets remaining, ~3 tests)
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
C:\data>hg bisect -c check.bat
Changeset 6:a7cab1800465: bad
Changeset 3:54349a6276cc: good
Changeset 4:d0a381a67072: bad
The first bad revision is:
changeset: 4:d0a381a67072
summary: bad1
Problem
Usually, at the end of a `hg bisect -c "my command"` I get note saying I should run `hg bisect --extend <ancestor_cset>` to continue my bisection deeper. I am using mercurial 2.1.2. Before mercurial 2.1, I the message was to use hg update instead of hg bisect --extend It becomes really annoying went the culprit cset is like 10 levels deep so I have to manually do this command 10 times `hg bisect --extend <ancestor_cset> && hg bisect -c "my command"`. Is there a way to just automate the --extend part and carry one with bisection until the culprit cset is found?