Bisect Extension (hbisect)
This extension is currently being distributed along with Mercurial.
Author: Benoit Benissot
This extension (hbisect) eases looking for bugs by doing a binary search in O(log(n)). It adds the bisect command.
This command comes from GIT. Its behaviour is fairly simple: it takes a first revision known to be correct (i.e. without the bug) and a last revision known to be bad (i.e. with the bug). The bisect extension ouputs a revision halfway between the good and the bad ones and lets you test it. If this revision is a good one, you mark it as good with hg bisect good, otherwise you mark it as bad with hg bisect bad. In both cases, bisect outputs a new revision to test, halfway between the good and the bad ones. You repeat until only one revision is left: the culprit.
First you configure your .hgrc to enable the extension by adding following lines:
Then, the bisect command should be available:
$ hg bisect help list of subcommands for the bisect extension bad mark revision as bad and update to the next revision to test good mark revision as good and update to the next revision to test help show help for a given bisect subcommand or all subcommands init start a new bisection next find and update to the next revision to test reset finish a bisection
To start a bug search, you initialize bisect:
$ hg bisect init
Usually, you have a bug in the tip, so you mark it as bad:
$ hg bisect bad
Then, you mark a revision known to be good:
$ hg bisect good ID-OF-KNOWN-GOOD 60 revisions left Now testing 6df5bc5a4e5fb898fd52689dad1ffce7059aba3e
After the above command, bisect outputs a new revision to test. After each test, you mark it as good with:
$ hg bisect good 15 revisions left Now testing 81d1c36e3205d2155fbccc49108dc55d8ba97758
or as bad with:
$ hg bisect bad 3 revisions left Now testing f2a1d841d57eeb3cdbc078f6e0f56c83a3f86a25
Until the right one is found:
$ hg bisect bad The first bad revision is : f2a1d841d57eeb3cdbc078f6e0f56c83a3f86a25