metaedit: use pre-checking before rewriting csets draft
authorSushil khanchi <sushilkhanchi97@gmail.com>
Wed, 04 Dec 2019 21:06:39 +0530
changeset 5235 a1cf66165e69
parent 5234 ea3f9e171b9a
child 5236 6c0797ec50b6
metaedit: use pre-checking before rewriting csets Changes in test file demonstrate the changed behaviour.
hgext3rd/evolve/cmdrewrite.py
tests/test-evolve-issue5958.t
tests/test-metaedit.t
--- a/hgext3rd/evolve/cmdrewrite.py	Sat Dec 14 13:31:45 2019 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Wed Dec 04 21:06:39 2019 +0530
@@ -881,20 +881,11 @@
             raise error.Abort(_(b'editing multiple revisions without --fold is '
                                 b'not currently supported'))
 
+        # pre-check
         if opts['fold']:
             root, head, p2 = rewriteutil.foldcheck(repo, revs)
         else:
-            if repo.revs(b"%ld and public()", revs):
-                raise error.Abort(_(b'cannot edit commit information for public '
-                                    b'revisions'))
-            newunstable = rewriteutil.disallowednewunstable(repo, revs)
-            if newunstable:
-                msg = _(b'cannot edit commit information in the middle'
-                        b' of a stack')
-                hint = _(b'%s will become unstable and new unstable changes'
-                         b' are not allowed')
-                hint %= repo[newunstable.first()]
-                raise error.Abort(msg, hint=hint)
+            rewriteutil.precheck(repo, revs, b'metaedit')
             root = head = repo[revs.first()]
             p2 = root.p2()
 
--- a/tests/test-evolve-issue5958.t	Sat Dec 14 13:31:45 2019 +0530
+++ b/tests/test-evolve-issue5958.t	Wed Dec 04 21:06:39 2019 +0530
@@ -7,6 +7,8 @@
   > [extensions]
   > rebase =
   > evolve =
+  > [experimental]
+  > evolution.allowdivergence = True
   > EOF
 
   $ hg init issue5958
--- a/tests/test-metaedit.t	Sat Dec 14 13:31:45 2019 +0530
+++ b/tests/test-metaedit.t	Wed Dec 04 21:06:39 2019 +0530
@@ -64,7 +64,8 @@
   $ hg update --clean .
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg metaedit -r 0
-  abort: cannot edit commit information for public revisions
+  abort: cannot metaedit public changesets: ea207398892e
+  (see 'hg help phases' for details)
   [255]
   $ hg metaedit --fold
   abort: revisions must be specified with --fold
@@ -81,8 +82,8 @@
   [255]
 check that metaedit respects allowunstable
   $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands'
-  abort: cannot edit commit information in the middle of a stack
-  (587528abfffe will become unstable and new unstable changes are not allowed)
+  abort: performing 'metaedit' in the middle of a stack will orphan 587528abfffe
+  (see 'hg help evolution.instability')
   [255]
   $ hg metaedit 'desc(A)::desc(B)' --fold --config 'experimental.evolution=createmarkers, allnewcommands'
   abort: performing 'fold' in the middle of a stack will orphan 3260958f1169 and its 3 descendants