views:

37

answers:

2

I have a bug that is present in one changeset but not its parent. Is there some functionality in mercurial where I can "update" in smaller increments, to see where the problem starts?

For example, if the diff is a change in functions A, B, and C, I would run the test suite after making each of those changes, to try to diagnose the problem.

A: 

You can use hg diff -r firstrev -r secondrev and filter the output to only the bits concerning those functions, then step through the patches one by one.

Or you could use the bisect extension, designed for this purpose - although it will give you all changes made to your codebase, not just those concerning a particular function. You could ameliorate this by extraction only the revs changing your function and then doing a bisection search of those revisions only.

Borealid
I thought bisect worked on a changset level, not a line-by-line level.
Rosarch
bisect does only work on the changeset level
heckj
Yes, I know bisect is change-by-change. I know.
Borealid
A: 

The answer is: it depends how much manual labor you are willing to put in.

What you can do is roll up your sleeves and use the attic extension in interactive mode. If you are using TortoiseHg, you already have it, just run hgtk shelve and it lets you move changes around one diff hunk at a time. (a hunk being a set of contiguous line diffs)

There are plenty of other diff patching tools that will give you single-hunk resolution. Let me know if you need more details.

And just for fun, let's talk about how an automated solution like bisect is not possible, since it doesn't always make sense that half a changeset should still compile. Even worse, what if they do compile, but have logic errors? Here's a simple worst case scenario...

void main(){
    Foo *x = malloc(128);
    frobFoo(&x);
-   free(x);   //line 4 removed in changeset
}

void frobFoo(Foo ** x){
+   free(*x);  //line 8 added in changeset
}
leo grrr