Undoing accidental hg amend on top of Mercurial queue
Faheem Mitha
faheem at faheem.info
Mon Mar 12 09:47:05 UTC 2018
Hello everyone,
The following sequence of commands requires that the Mercurial Queues
exension be enabled, and also the Evolve extension (for `hg amend`,
alias `hg refresh`).
This combination of commands messes up the existing Mercurial queue,
making the commit corresponding to the pushed patch obsolete, and
creating a new commit with exactly the same contents.
This error is in theory quite easy to make: just type `hg ref` instead
of `hg qref`, but I just made it recently after using Mercurial Queues
for years. Regardless, I haven't figured out a clean way to fix this
and get back the original state.
Note that a simple `hg rollback` does work in my example, but I'm not
sure it will work in my case, because I've tried other things trying
to fix this. In any case, `hg rollback` isn't something one should
rely on. In summary, how do I undo the `hg amend` and get back my
applied MQ patch?
I've also posted this on Stack Overflow -
https://stackoverflow.com/q/49219477/350713
I've found that running strip on the top level changeset appears to fix
the issue, but I'm not sure if that's the best way of handling this. I
would have thought something like touch would be more appropriate, but
that either doesn't work, or makes things worse.
Transcript follows.
Please CC me on any reply. Thanks in advance.
Regards, Faheem Mitha
######################################################################
#!/bin/sh
cd /tmp
hg init test
cd test
echo "This is foo" >> foo
hg add
hg ci -m "Add foo"
hg init --mq
echo "Line 2 of foo" >> foo
hg qnew p
hg ci --mq -m "Add patch p"
hg ref
hg log -vG --hidden
@ changeset: 2:16592b49676e
| tag: tip
| parent: 0:31a3f37ddd33
| user: Faheem Mitha <faheem at faheem.info>
| date: Mon Mar 12 11:04:45 2018 +0530
| files: foo
| description:
| [mq]: p
|
|
| x changeset: 1:c00213b8eb4d
|/ tag: p
| tag: qbase
| tag: qtip
| user: Faheem Mitha <faheem at faheem.info>
| date: Mon Mar 12 11:04:43 2018 +0530
| obsolete: rewritten using amend as 2:16592b49676e by Faheem Mitha
<faheem at faheem.info> (at 2018-03-12 11:04 +0530)
| obsolete: rewritten by Faheem Mitha <faheem at faheem.info> as
16592b49676e (at 2018-03-12 11:04 +0530)
| files: foo
| description:
| [mq]: p
|
|
o changeset: 0:31a3f37ddd33
tag: qparent
user: Faheem Mitha <faheem at faheem.info>
date: Mon Mar 12 11:04:43 2018 +0530
files: foo
description:
Add foo
hg strip -r 2 --hidden
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
saved backup bundle to
/tmp/test.tmp/.hg/strip-backup/16592b49676e-618a5424-backup.hg
hg log -vG --hidden
o changeset: 1:c00213b8eb4d
| tag: p
| tag: qbase
| tag: qtip
| tag: tip
| user: Faheem Mitha <faheem at faheem.info>
| date: Mon Mar 12 11:04:43 2018 +0530
| files: foo
| description:
| [mq]: p
|
|
@ changeset: 0:31a3f37ddd33
tag: qparent
user: Faheem Mitha <faheem at faheem.info>
date: Mon Mar 12 11:04:43 2018 +0530
files: foo
description:
Add foo
More information about the Evolve-testers
mailing list