unamend: error out when running on merge commit
It's better to error out than to produce a bad commit. We do that same
in `hg uncommit`. I haven't looked into how much work it is to make
them work instead.
Differential Revision: https://phab.mercurial-scm.org/D12087
--- a/hgext/uncommit.py Mon Jan 24 21:12:19 2022 -0800
+++ b/hgext/uncommit.py Mon Jan 24 21:17:04 2022 -0800
@@ -273,6 +273,8 @@
curctx = repo[b'.']
rewriteutil.precheck(repo, [curctx.rev()], b'unamend')
+ if len(curctx.parents()) > 1:
+ raise error.InputError(_(b"cannot unamend merge changeset"))
# identify the commit to which to unamend
markers = list(predecessormarkers(curctx))
--- a/tests/test-unamend.t Mon Jan 24 21:12:19 2022 -0800
+++ b/tests/test-unamend.t Mon Jan 24 21:17:04 2022 -0800
@@ -443,8 +443,5 @@
A left
$ hg amend
$ hg unamend
- $ hg st --rev 1 --rev .
- A right
- R left (known-bad-output !)
- $ hg st --rev 2 --rev .
- A left (missing-correct-output !)
+ abort: cannot unamend merge changeset
+ [10]