Patchwork D7685: rebase: use rewriteutil.precheck() instead of reimplementing it

login
register
mail settings
Submitter phabricator
Date Dec. 18, 2019, 6:48 a.m.
Message ID <05df90091206b13287585f3da666ae49@localhost.localdomain>
Download mbox | patch
Permalink /patch/43973/
State Not Applicable
Headers show

Comments

phabricator - Dec. 18, 2019, 6:48 a.m.
Closed by commit rHG71fee4564410: rebase: use rewriteutil.precheck() instead of reimplementing it (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7685?vs=18829&id=18860

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7685/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7685

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-collapse.t
  tests/test-rebase-scenario-global.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel
Yuya Nishihara - Dec. 18, 2019, 3:06 p.m.
> -                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'

Missed `_()`?
phabricator - Dec. 18, 2019, 3:11 p.m.
yuja added a comment.


  > - 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'
  
  Missed `_()`?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7685/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7685

To: martinvonz, #hg-reviewers, pulkit
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -325,14 +325,15 @@ 
 
   $ hg pull --config phases.publish=True -q -r 6 . # update phase of 6
   $ hg rebase -d 0 -b 6
-  nothing to rebase
-  [1]
+  abort: cannot rebase public changesets
+  (see 'hg help phases' for details)
+  [255]
   $ hg rebase -d 5 -b 6
-  abort: can't rebase public changeset e1c4361dd923
+  abort: cannot rebase public changesets
   (see 'hg help phases' for details)
   [255]
   $ hg rebase -d 5 -r '1 + (6::)'
-  abort: can't rebase public changeset e1c4361dd923
+  abort: cannot rebase public changesets
   (see 'hg help phases' for details)
   [255]
 
@@ -452,7 +453,7 @@ 
   $ hg clone -q -u . ah ah1
   $ cd ah1
   $ hg rebase -r '2::8' -d 1
-  abort: can't remove original changesets with unrebased descendants
+  abort: cannot rebase changeset with children
   (use --keep to keep original changesets)
   [255]
   $ hg rebase -r '2::8' -d 1 -k
@@ -498,7 +499,7 @@ 
   $ hg clone -q -u . ah ah2
   $ cd ah2
   $ hg rebase -r '3::8' -d 1
-  abort: can't remove original changesets with unrebased descendants
+  abort: cannot rebase changeset with children
   (use --keep to keep original changesets)
   [255]
   $ hg rebase -r '3::8' -d 1 --keep
@@ -541,7 +542,7 @@ 
   $ hg clone -q -u . ah ah3
   $ cd ah3
   $ hg rebase -r '3::7' -d 1
-  abort: can't remove original changesets with unrebased descendants
+  abort: cannot rebase changeset with children
   (use --keep to keep original changesets)
   [255]
   $ hg rebase -r '3::7' -d 1 --keep
@@ -581,7 +582,7 @@ 
   $ hg clone -q -u . ah ah4
   $ cd ah4
   $ hg rebase -r '3::(7+5)' -d 1
-  abort: can't remove original changesets with unrebased descendants
+  abort: cannot rebase changeset with children
   (use --keep to keep original changesets)
   [255]
   $ hg rebase -r '3::(7+5)' -d 1 --keep
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -592,7 +592,7 @@ 
   o  0: f447d5abf5ea 'add'
   
   $ hg rebase --collapse -r 1 -d 0
-  abort: can't remove original changesets with unrebased descendants
+  abort: cannot rebase changeset with children
   (use --keep to keep original changesets)
   [255]
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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())