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>
qnew
: you can directly use the qcrefresh
command to exclude the changes that were not meant to be included. The excluded changes will remain as local changes, so after qcrefresh
you can include them all in a new patch with qnew
or even use qcrecord
to only select a subset of them. –
Rubberneck hg qnew
on a modified repository, which ends as if qnew
was never invoked? I tried to this using qrefresh
before (which I suppose does the same thing as qcrefresh
, only non-interactively), but without success. –
Anuradhapura qrefresh
--include
and --exclude
options you can select which files to include in the patch qcrecord
lets you choose the single hunks. –
Rubberneck © 2022 - 2024 — McMap. All rights reserved.
qnew
that has already happened. – Anuradhapura