changeset 2789:06ee4ec88190

prune: use precheck to validate revision This gives us standard check and standard error message.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 23 Jul 2017 21:21:11 +0200
parents 554c069cdc85
children 1b7b9acda2a9
files hgext3rd/evolve/cmdrewrite.py tests/test-evolve.t tests/test-prune.t
diffstat 3 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Mon Jul 24 01:45:17 2017 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Jul 23 21:21:11 2017 +0200
@@ -636,24 +636,17 @@
     try:
         wlock = repo.wlock()
         lock = repo.lock()
+        rewriteutil.precheck(repo, revs, 'touch')
         tr = repo.transaction('prune')
         # defines pruned changesets
         precs = []
         revs.sort()
         for p in revs:
             cp = repo[p]
-            if not cp.mutable():
-                # note: createmarkers() would have raised something anyway
-                raise error.Abort('cannot prune immutable changeset: %s' % cp,
-                                  hint="see 'hg help phases' for details")
             precs.append(cp)
         if not precs:
             raise error.Abort('nothing to prune')
 
-        if rewriteutil.disallowednewunstable(repo, revs):
-            raise error.Abort(_("cannot prune in the middle of a stack"),
-                              hint=_("new unstable changesets are not allowed"))
-
         # defines successors changesets
         sucs = scmutil.revrange(repo, succs)
         sucs.sort()
--- a/tests/test-evolve.t	Mon Jul 24 01:45:17 2017 +0200
+++ b/tests/test-evolve.t	Sun Jul 23 21:21:11 2017 +0200
@@ -145,7 +145,7 @@
   $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
   1 public 
   $ hg prune 1
-  abort: cannot prune immutable changeset: 7c3bad9141dc
+  abort: cannot touch public changesets: 7c3bad9141dc
   (see 'hg help phases' for details)
   [255]
   $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
@@ -1339,12 +1339,12 @@
   $ mkcommit c5_
   created new head
   $ hg prune '26 + 27'
-  abort: cannot prune in the middle of a stack
-  (new unstable changesets are not allowed)
+  abort: touch will orphan 1 descendants
+  (see 'hg help evolution.instability')
   [255]
   $ hg prune '19::28'
-  abort: cannot prune in the middle of a stack
-  (new unstable changesets are not allowed)
+  abort: touch will orphan 1 descendants
+  (see 'hg help evolution.instability')
   [255]
   $ hg prune '26::'
   3 changesets pruned
--- a/tests/test-prune.t	Mon Jul 24 01:45:17 2017 +0200
+++ b/tests/test-prune.t	Sun Jul 23 21:21:11 2017 +0200
@@ -86,7 +86,7 @@
 cannot prune public changesets
 
   $ hg prune 0
-  abort: cannot prune immutable changeset: 1f0dee641bb7
+  abort: cannot touch public changesets: 1f0dee641bb7
   (see 'hg help phases' for details)
   [255]
   $ hg debugobsolete