D7176: rebase: allow rebasing obsolete commit without successor

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Oct 25 20:49:19 EDT 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When trying to rebase an obsolete whose successors are also all
  obsolete, we would skip it and tell the user that it would have caused
  divergence. That is not correct. We could just change the message, but
  I don't see any harm in rebasing such commits. It even seems like a
  reasonable way to make it not obsolete. So this patch makes that type
  of rebase allowed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1538,9 +1538,8 @@
   1 new obsolescence markers
   obsoleted 1 changesets
   $ hg tag --local --remove E
-BROKEN: this rebase would not cause divergence
   $ hg rebase -d D -s C
-  note: not rebasing 3:26805aba1e60 "C" (C) and its descendants as this would cause divergence
+  rebasing 3:26805aba1e60 "C" (C)
 
   $ cd ..
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -204,6 +204,7 @@
         self.keepbranchesf = opts.get(b'keepbranches', False)
         self.obsoletenotrebased = {}
         self.obsoletewithoutsuccessorindestination = set()
+        self.obsoleteextinctsuccessors = set()
         self.inmemory = inmemory
         self.stateobj = statemod.cmdstate(repo, b'rebasestate')
 
@@ -357,11 +358,11 @@
         (
             self.obsoletenotrebased,
             self.obsoletewithoutsuccessorindestination,
-            obsoleteextinctsuccessors,
+            self.obsoleteextinctsuccessors,
         ) = _computeobsoletenotrebased(self.repo, obsoleteset, destmap)
         skippedset = set(self.obsoletenotrebased)
         skippedset.update(self.obsoletewithoutsuccessorindestination)
-        skippedset.update(obsoleteextinctsuccessors)
+        skippedset.update(self.obsoleteextinctsuccessors)
         _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
 
     def _prepareabortorcontinue(self, isabort, backup=True, suppwarns=False):
@@ -576,6 +577,7 @@
         elif (
             not allowdivergence
             and rev in self.obsoletewithoutsuccessorindestination
+            and rev not in self.obsoleteextinctsuccessors
         ):
             msg = (
                 _(



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


More information about the Mercurial-devel mailing list