unamend: error out when running on merge commit stable
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 24 Jan 2022 21:17:04 -0800
branchstable
changeset 48581 4f01821fa0ec
parent 48580 f1898680d713
child 48582 2b271cab2d1c
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
hgext/uncommit.py
tests/test-unamend.t
--- 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]