--- a/hgext/uncommit.py Thu Mar 17 14:58:46 2022 +0100
+++ b/hgext/uncommit.py Mon Mar 21 14:21:10 2022 -0700
@@ -276,6 +276,15 @@
if len(curctx.parents()) > 1:
raise error.InputError(_(b"cannot unamend merge changeset"))
+ expected_keys = (b'amend_source', b'unamend_source')
+ if not any(key in curctx.extra() for key in expected_keys):
+ raise error.InputError(
+ _(
+ b"working copy parent was not created by 'hg amend' or "
+ b"'hg unamend'"
+ )
+ )
+
# identify the commit to which to unamend
markers = list(predecessormarkers(curctx))
if len(markers) != 1: