Splitting a Changeset/Patch

Wednesday, February 13th, 2008

I have a common problem with revision control:

  1. Clone a tree
  2. Start working on a problem X (say, adding valgrind annotations to MMgc) with edits to GC.cpp
  3. Get distracted and start working on problem Y (say, MMgc crashing) with edits to GC.cpp
  4. I now have unrelated changes in GC.cpp that I’d like to separate.

Dear lazyweb, is there a tool I can use to interactively separate out these changes into two changesets? The solution should work with my mercurial workflow, no “use git-rebase” comments please. I happen to be using patch queues, but a solution that worked on real mercurial changesets or on raw patches would also be acceptable. It happens that usually the patch hunks for problem X and problem Y are completely separate, so a simple tool that let me throw “this hunk for X, this hunk for Y” would probably be ok. Better would be something like a three-way merge tool where I can edit an intermediate state between a fixed start-point and end-point.