The bisect
command helps you to track down the changeset that introduced a bug.
Reset the bisect state and mark the current revision as bad (it contains the bug!)
hg bisect --reset
hg bisect --bad
Go back to a point where you think the bug isn't present
hg update -r -200
Now you've to test the software and if your assumption was right (bug not present), mark the revision as good:
hg bisect --good
Testing changeset 800:12ab34cd56ef (x changesets remaining, ~y tests)
Mercurial updates the current revision (somewhere in the middle between the bad and good changeset)
Test again the software and mark appropriately the current revision. E.g.
hg bisect --good
Testing changeset 900:21ba43dc65fe (x changesets remaining, ~y tests)
...
Continue until Mercurial has narrowed the search down to a single changeset:
hg bisect --bad
The first bad revision is:
changeset: 987:1234bad99889
user: John Doe [email protected]
date: Jul 28 16:00:00 2016
The hg bisect
command uses its knowledge of your project's revision history to perform a search in time proportional to the logarithm of the number of changesets to check and has no problems dealing with branches, merges or multiple heads.
Sometimes you have an idea of the incriminated files and you can give an hint to Mercurial:
hg bisect --skip "!( file('path:foo') & file('path:bar') )"
This skips all revisions that do not touch directories foo
or bar
.