2

Is there a program (preferably available on Cygwin) which I can use to "filter" a diff file interactively? i.e. I want something like git interactive add, except that I want to operate on a diff file. I have already discovered filterdiff, but I don't think that it supports interactive editing, only inclusion/exclusion of hunks based on a pre-defined search criteria.

My usage scenario: I have a patch in MQ, which I would like to split up per the tutorial here: https://www.mercurial-scm.org/wiki/MqTutorial#Split_a_patch_into_multiple_patches. In order to do so, I have to edit a patch file so that it includes only the (many) changes I want, and doing this manually with a text editor is kind of a pain.

Thanks!

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
fyhuang
  • 2,147
  • 5
  • 21
  • 24

2 Answers2

3

You can probably get what you want using the record extension: https://www.mercurial-scm.org/wiki/RecordExtension

Apply the patch (but don't commit it) and then selectively commit chunk by chunk using record. You could do that with or without mq in the works.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • Thanks, I didn't know about this! I eventually got what I wanted using a combination of the record extension, reapplying the full patch, and manually fixing bad hunks, but it would have been nice to have a GUI tool or something. (In particular, I wanted to keep/extract individual lines in several hunks.) – fyhuang Aug 09 '11 at 17:35
0

Emacs’ diff-mode has commands to (un)apply or delete individual hunks of a diff. It also allows editing the hunks (keeping the hunk headers up to date automatically), and it has a hunk-split command that is a bit more powerful than that in git add -p.

Davis Herring
  • 36,443
  • 4
  • 48
  • 76