# HG changeset patch # User Martin von Zweigbergk # Date 2022-01-25 05:17:04 # Node ID 4f01821fa0ec7a1d68e06b8ffdb0ddf48a677dc6 # Parent f1898680d713c97702af0655dae43f4311460807 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 diff --git a/hgext/uncommit.py b/hgext/uncommit.py --- a/hgext/uncommit.py +++ b/hgext/uncommit.py @@ -273,6 +273,8 @@ def unamend(ui, repo, **opts): 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)) 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 @@ Try to unamend a merge 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]