SubOne
SubOne

Reputation: 633

Interactively split diff

How do I interactively split a single diff file into two or more diff files?

I use the mercurial hg diff command to generate diffs. I'd like to separate a large change set into multiple smaller change sets with code changes that are like. This can really only be done interactively. I'd like to be prompted with each change or line of change and choose which of multiple files to save to. Preferably with the option to edit inline if needed.

Upvotes: 2

Views: 1022

Answers (1)

hlovdal
hlovdal

Reputation: 28238

I am not sure if you can use a diff file directly, but if you apply the diff file so that you get two different versions of the file you can use KDiff3 to do a interactive merge where you select which of the changes you want. You can either select verbatim copy from source files or you can edit the result manually.

KDiff3 session example

If you start with say file_100.c and file_200.c as the start/end points which you would like to have split into three separate changes (e.g. you would like to have say file_150.c and a file_175.c version inbetween), then merge file_100.c and file_200.c and save output to file_150.c. Next step is merging file_150.c and file_200.c into file_175.c.

If you want to mostly select changes from one of the versions you can just specify that file twice and do a 3-way merge with those changes automatically selected (if you have a common base you can of course alternatively do a real 3-way merge).

KDiff3 is a wonderful tool that I highly recommend.

Upvotes: 1

Related Questions