changeset 2786:ae690d39fc92

split: 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 20:33:19 +0200
parents b5a48e4aeec6
children ebca049e8ca9
files README hgext3rd/evolve/cmdrewrite.py tests/test-split.t
diffstat 3 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/README	Mon Jul 24 01:45:03 2017 +0200
+++ b/README	Sun Jul 23 20:33:19 2017 +0200
@@ -126,6 +126,7 @@
 
   - amend: add a --extract flag to move change back to the working copy
     (same as uncommit, but accessible through the amend commit)
+  - split: now properly refuse to split public changeset
   - uncommit: add support for --current-date and --current-user option
   - fold: add support for --current-date and --current-user option
   - metaedit: add support for --current-date and --current-user option
--- a/hgext3rd/evolve/cmdrewrite.py	Mon Jul 24 01:45:03 2017 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Jul 23 20:33:19 2017 +0200
@@ -781,14 +781,9 @@
         lock = repo.lock()
         rev = scmutil.revsingle(repo, revarg[0])
         cmdutil.bailifchanged(repo)
+        rewriteutil.precheck(repo, [rev], action='split')
         tr = repo.transaction('split')
         ctx = repo[rev]
-        disallowunstable = not obsolete.isenabled(repo,
-                                                  obsolete.allowunstableopt)
-        if disallowunstable:
-            # XXX We should check head revs
-            if repo.revs("(%d::) - %d", rev, rev):
-                raise error.Abort(_("cannot split commit: %s not a head") % ctx)
 
         if len(ctx.parents()) > 1:
             raise error.Abort(_("cannot split merge commits"))
--- a/tests/test-split.t	Mon Jul 24 01:45:03 2017 +0200
+++ b/tests/test-split.t	Sun Jul 23 20:33:19 2017 +0200
@@ -131,10 +131,21 @@
   $ hg split
   abort: uncommitted changes
   [255]
+  $ hg up "desc(_c)" -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+Cannot split public changeset
+
+  $ hg phase --rev 'desc("_a")'
+  0: draft
+  $ hg phase --rev 'desc("_a")' --public
+  $ hg split --rev 'desc("_a")'
+  abort: cannot split public changesets: 135f39f4bd78
+  (see 'hg help phases' for details)
+  [255]
+  $ hg phase --rev 'desc("_a")' --draft --force
 
 Split a revision specified with -r
-  $ hg up "desc(_c)" -C
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo "change to b" >> _b
   $ hg amend -m "_cprim"
   2 new unstable changesets
@@ -338,7 +349,8 @@
   > evolutioncommands=split
   > EOF
   $ hg split -r "desc(split3)"
-  abort: cannot split commit: ead2066d1dbf not a head
+  abort: split will orphan 4 descendants
+  (see 'hg help evolution.instability')
   [255]
 
 Changing evolution level to createmarkers