unamend: allow unamending if allowunstable is set
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 13 Dec 2017 17:03:39 -0800
changeset 35435 f01101100043
parent 35434 71446ca85813
child 35436 31d21309635b
unamend: allow unamending if allowunstable is set I don't see why unamend should be disallowed when allowunstable is set. By switching to rewriteutil.precheck() we fix that and get more consistent error messages (and some additional ones). Differential Revision: https://phab.mercurial-scm.org/D1682
hgext/uncommit.py
tests/test-unamend.t
--- a/hgext/uncommit.py	Wed Dec 13 10:29:22 2017 -0800
+++ b/hgext/uncommit.py	Wed Dec 13 17:03:39 2017 -0800
@@ -208,8 +208,7 @@
         # identify the commit from which to unamend
         curctx = repo['.']
 
-        if not curctx.mutable():
-            raise error.Abort(_('cannot unamend public changesets'))
+        rewriteutil.precheck(repo, [curctx.rev()], 'unamend')
 
         # identify the commit to which to unamend
         markers = list(predecessormarkers(curctx))
@@ -220,9 +219,6 @@
         prednode = markers[0].prednode()
         predctx = unfi[prednode]
 
-        if curctx.children():
-            raise error.Abort(_("cannot unamend a changeset with children"))
-
         # add an extra so that we get a new hash
         # note: allowing unamend to undo an unamend is an intentional feature
         extras = predctx.extra()
--- a/tests/test-unamend.t	Wed Dec 13 10:29:22 2017 -0800
+++ b/tests/test-unamend.t	Wed Dec 13 17:03:39 2017 -0800
@@ -280,17 +280,20 @@
   o  0:18d04c59bb5d  Added a
   
 
+  $ hg --config experimental.evolution=createmarkers unamend
+  abort: cannot unamend changeset with children
+  [255]
+
   $ hg unamend
-  abort: cannot unamend a changeset with children
-  [255]
 
 Trying to unamend a public changeset
 
-  $ hg up
-  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg up -C 23
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg phase -r . -p
   $ hg unamend
   abort: cannot unamend public changesets
+  (see 'hg help phases' for details)
   [255]
 
 Testing whether unamend retains copies or not