hgext/rebase.py
changeset 43934 71fee4564410
parent 43932 9fb9f3a5cad7
child 43940 d77230743968
--- a/hgext/rebase.py	Tue Dec 17 10:53:51 2019 -0800
+++ b/hgext/rebase.py	Wed Dec 18 09:18:02 2019 +0300
@@ -46,6 +46,7 @@
     repair,
     revset,
     revsetlang,
+    rewriteutil,
     scmutil,
     smartset,
     state as statemod,
@@ -393,17 +394,13 @@
             return _nothingtorebase()
 
         rebaseset = destmap.keys()
-        allowunstable = obsolete.isenabled(self.repo, obsolete.allowunstableopt)
-        if not (self.keepf or allowunstable) and self.repo.revs(
-            b'first(children(%ld) - %ld)', rebaseset, rebaseset
-        ):
-            raise error.Abort(
-                _(
-                    b"can't remove original changesets with"
-                    b" unrebased descendants"
-                ),
-                hint=_(b'use --keep to keep original changesets'),
-            )
+        if not self.keepf:
+            try:
+                rewriteutil.precheck(self.repo, rebaseset, action=b'rebase')
+            except error.Abort as e:
+                if e.hint is None:
+                    e.hint = b'use --keep to keep original changesets'
+                raise e
 
         result = buildstate(self.repo, destmap, self.collapsef)
 
@@ -412,13 +409,6 @@
             self.ui.status(_(b'nothing to rebase\n'))
             return _nothingtorebase()
 
-        for root in self.repo.set(b'roots(%ld)', rebaseset):
-            if not self.keepf and not root.mutable():
-                raise error.Abort(
-                    _(b"can't rebase public changeset %s") % root,
-                    hint=_(b"see 'hg help phases' for details"),
-                )
-
         (self.originalwd, self.destmap, self.state) = result
         if self.collapsef:
             dests = set(self.destmap.values())