Patchwork D10258: reabase: call rewriteutil.precheck() a bit later

login
register
mail settings
Submitter phabricator
Date March 24, 2021, 6:25 a.m.
Message ID <differential-rev-PHID-DREV-a4ywcl5srb7zuqh6f3i5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48574/
State Superseded
Headers show

Comments

phabricator - March 24, 2021, 6:25 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We now filter out descendants of divergence-causing commits in
  `_handleskippingobsolete()`. The filtered-out commits are removed from
  the rebase set (`destmap` and `state`). We should therefore call
  `rewriteutil.precheck()` after `_handleskippingobsolete()`. This patch
  does that. It hasn't mattered so far because `rewriteutil.precheck()`
  doesn't yet check for divergence, but it will soon.
  
  This affects one test where we now fail because the user is trying to
  rebase an ancestor instead of failing because they tried to rebase a
  public commit. We have several similar tests just after, where we
  still fail because of the phase, so that seems fine. The difference in
  behavior also seems fine to me.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, 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,9 +325,8 @@ 
 
   $ hg pull --config phases.publish=True -q -r 6 . # update phase of 6
   $ hg rebase -d 0 -b 6
-  abort: cannot rebase public changesets
-  (see 'hg help phases' for details)
-  [10]
+  nothing to rebase
+  [1]
   $ hg rebase -d 5 -b 6
   abort: cannot rebase public changesets
   (see 'hg help phases' for details)
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -413,15 +413,6 @@ 
         if not destmap:
             return _nothingtorebase()
 
-        rebaseset = destmap.keys()
-        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)
 
         if not result:
@@ -450,6 +441,15 @@ 
         # Calculate self.obsolete_* sets
         self._handleskippingobsolete()
 
+        rebaseset = destmap.keys()
+        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
+
         self.prepared = True
 
     def _assignworkingcopy(self):