Bisect Extension (hbisect)

1. Status

Mercurial 1.0 onwards includes bisect as a built-in command (see UpgradeNotes and hg bisect).

Author: Benoit Boissinot

2. Overview

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.

3. Configuration

First you configure your $HOME/.hgrc to enable the extension by adding following lines (this is not needed for Mercurial 1.0):

[extensions]
hgext.hbisect=

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

For Mercurial 1.0, bisect is a built-in command:

$ hg help bisect
hg bisect [-gbsr] [REV]

subdivision search of changesets

    This command helps to find changesets which introduce problems.
    To use, mark the earliest changeset you know exhibits the problem
    as bad, then mark the latest changeset which is free from the
    problem as good. Bisect will update your working directory to a
    revision for testing. Once you have performed tests, mark the
    working directory as bad or good and bisect will either update to
    another candidate changeset or announce that it has found the bad
    revision.

options:

 -r --reset     reset bisect state
 -g --good      mark changeset good
 -b --bad       mark changeset bad
 -s --skip      skip testing changeset
 -U --noupdate  do not update to target

use "hg -v help bisect" to show global options

4. Usage

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


CategoryBundledExtension CategoryHistorical

日本語

BisectExtension (last edited 2017-10-06 13:34:39 by tonfa)