35

I have large MQ patch applied in Mercurial. What has happened is I have done qrefresh and included files in my patch that I do not want to include. Is there a way to remove the changes to these file from my patch with out manually editing it? In this case if I was just working without MQ, all I would have to do is hg revert.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
Nathan Lee
  • 2,231
  • 2
  • 23
  • 26

3 Answers3

46

With the patch applied:

hg qrefresh -X [file1] -X [file2] ... -X [fileN]

Will take out file1 to fileN of the patch. After completing that, type hg status to verify that the files are now marked as modified, and therefore not part of the patch any longer .

jan
  • 2,741
  • 4
  • 35
  • 56
TaiKor
  • 476
  • 5
  • 3
  • 3
    The `-X` switch has to come before each file name. So to remove foo and bar, use `hg qrefresh -X foo -X bar`. – nmichaels Mar 21 '12 at 20:55
  • If you want to remove all files from the patch, instead of remove each file, you could run `hg qrefresh -X '*'`. You must surround the `*` character with `'` to prevent the shell to interpret before the mercurial. – Bernardo Pacheco Mar 25 '15 at 20:16
  • This one doesn't seem to work in 4.8 for Windows. I used `-X` and `--exclude`, using full filename and glob, in quotes and without them, nothing works. `hg qdiff --stat` returns file list unchanged – EvgeniySharapov Nov 09 '18 at 20:31
2

I think you can use make the patch the current patch (applied and at the top of the stack) and then hg forget and hg qrefresh.

And of course hg forget is just hg remove without requiring extra options to avoid file deletion.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
1

The easiest way to do this is to do hg qrefresh with all the files except the one you want to remove - that'll take the changes out of the patch without discarding them.

durin42
  • 1,447
  • 8
  • 10