changeset 48581:4f01821fa0ec stable

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
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 24 Jan 2022 21:17:04 -0800
parents f1898680d713
children 2b271cab2d1c
files hgext/uncommit.py tests/test-unamend.t
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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]