I issued hg qnew
without realizing that it includes any outstanding changes into the patch. I'd like to back that out and pick only specific changes using hg qrecord
. How can I undo qnew
?
Your answer definitely works — with newer Mercurial's you can use hg strip --keep
to avoid doing the import step:
$ hg strip --keep .
$ hg qdelete patch-name
The --keep
flag makes strip ignore the working copy while working, that is, it deletes the commit (like hg qpop
would do) but it doesn't undo the changes to the files. After stripping you still have the patch in your series (unapplied) and you can then delete it.
I've found an anwer here:
hg qpop
hg import --no-commit .hg/patches/patch-name
hg qdelete patch-name
Please add a better way, if you know.
Update: Based on Aldo's answer, there is another way:
hg qnew test
# We can undo the above qnew as:
hg qrefresh -X '*'
hg qpop -f
hg qdelete test
If you just want to undo the latest qnew
retaining all your local changes, one option is:
qcrefresh 123
hg qpop -f
hg qdelete <name of the patch>
Notice that 123
is just a random string: you are telling mercurial to only include the (hopefully nonexistsnt) 123
file in the current patch.
Newer versions of Mercurial When you issue will issue a warning about the fact 123
file does not exist, but this is exactly what we want here.
If you want to retain some of the changes in the current path, you can use the qcrefresh
command from the crecord extension, which allows to graphically select the changes to be included in the current patch. You need to download it from Bitbucket, extract the archive and configure it in .hgrc
:
[extensions]
crecord = <path/to/crecord/package>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With