Patchwork D12087: unamend: error out when running on merge commit

login
register
mail settings
Submitter phabricator
Date Jan. 25, 2022, 5:17 a.m.
Message ID <differential-rev-PHID-DREV-2htkge2jg2xdyjd3pcwp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50413/
State New
Headers show

Comments

phabricator - Jan. 25, 2022, 5:17 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12087

AFFECTED FILES
  hgext/uncommit.py
  tests/test-unamend.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -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]
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -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))