D10248: rebase: clarify names of variables and function related to obsolete revisions

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Mar 22 17:37:04 UTC 2021


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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -205,8 +205,8 @@
         self.skipemptysuccessorf = rewriteutil.skip_empty_successor(
             repo.ui, b'rebase'
         )
-        self.obsoletenotrebased = {}
-        self.obsoletewithoutsuccessorindestination = set()
+        self.obsolete_with_successor_in_destination = {}
+        self.obsolete_would_cause_divergence = set()
         self.inmemory = inmemory
         self.dryrun = dryrun
         self.stateobj = statemod.cmdstate(repo, b'rebasestate')
@@ -351,16 +351,16 @@
     def _handleskippingobsolete(self):
         """Compute structures necessary for skipping obsolete revisions"""
         obsoleterevs = {r for r in self.state if self.repo[r].obsolete()}
-        self.obsoletenotrebased = {}
+        self.obsolete_with_successor_in_destination = {}
         if not self.ui.configbool(b'experimental', b'rebaseskipobsolete'):
             return
         obsoleteset = set(obsoleterevs)
         (
-            self.obsoletenotrebased,
-            self.obsoletewithoutsuccessorindestination,
-        ) = _computeobsoletenotrebased(self.repo, obsoleteset, self.destmap)
-        skippedset = set(self.obsoletenotrebased)
-        skippedset.update(self.obsoletewithoutsuccessorindestination)
+            self.obsolete_with_successor_in_destination,
+            self.obsolete_would_cause_divergence,
+        ) = _compute_obsolete_sets(self.repo, obsoleteset, self.destmap)
+        skippedset = set(self.obsolete_with_successor_in_destination)
+        skippedset.update(self.obsolete_would_cause_divergence)
         _checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
 
     def _prepareabortorcontinue(
@@ -369,7 +369,7 @@
         self.resume = True
         try:
             self.restorestatus()
-            # Calculate self.obsoletenotrebased
+            # Calculate self.obsolete_* sets
             self._handleskippingobsolete()
             self.collapsemsg = restorecollapsemsg(self.repo, isabort)
         except error.RepoLookupError:
@@ -437,7 +437,7 @@
 
         self.prepared = True
 
-        # Calculate self.obsoletenotrebased
+        # Calculate self.obsolete_* sets
         self._handleskippingobsolete()
 
     def _assignworkingcopy(self):
@@ -502,8 +502,8 @@
             if not allowdivergence:
                 sortedrevs -= self.repo.revs(
                     b'descendants(%ld) and not %ld',
-                    self.obsoletewithoutsuccessorindestination,
-                    self.obsoletewithoutsuccessorindestination,
+                    self.obsolete_would_cause_divergence,
+                    self.obsolete_would_cause_divergence,
                 )
             for rev in sortedrevs:
                 self._rebasenode(tr, rev, allowdivergence, progress)
@@ -575,8 +575,7 @@
         if self.state[rev] == rev:
             ui.status(_(b'already rebased %s\n') % desc)
         elif (
-            not allowdivergence
-            and rev in self.obsoletewithoutsuccessorindestination
+            not allowdivergence and rev in self.obsolete_would_cause_divergence
         ):
             msg = (
                 _(
@@ -587,8 +586,8 @@
             )
             repo.ui.status(msg)
             self.skipped.add(rev)
-        elif rev in self.obsoletenotrebased:
-            succ = self.obsoletenotrebased[rev]
+        elif rev in self.obsolete_with_successor_in_destination:
+            succ = self.obsolete_with_successor_in_destination[rev]
             if succ is None:
                 msg = _(b'note: not rebasing %s, it has no successor\n') % desc
             else:
@@ -614,7 +613,7 @@
                 self.destmap,
                 self.state,
                 self.skipped,
-                self.obsoletenotrebased,
+                self.obsolete_with_successor_in_destination,
             )
             if self.resume and self.wctx.p1().rev() == p1:
                 repo.ui.debug(b'resuming interrupted rebase\n')
@@ -726,7 +725,7 @@
                 self.destmap,
                 self.state,
                 self.skipped,
-                self.obsoletenotrebased,
+                self.obsolete_with_successor_in_destination,
             )
             editopt = opts.get(b'edit')
             editform = b'rebase.collapse'
@@ -2180,17 +2179,17 @@
     return ret
 
 
-def _computeobsoletenotrebased(repo, rebaseobsrevs, destmap):
-    """Return (obsoletenotrebased, obsoletewithoutsuccessorindestination).
+def _compute_obsolete_sets(repo, rebaseobsrevs, destmap):
+    """Figure out what to do about about obsolete revisions
 
-    `obsoletenotrebased` is a mapping mapping obsolete => successor for all
+    `obsolete_with_successor_in_destination` is a mapping mapping obsolete => successor for all
     obsolete nodes to be rebased given in `rebaseobsrevs`.
 
-    `obsoletewithoutsuccessorindestination` is a set with obsolete revisions
-    without a successor in destination.
+    `obsolete_would_cause_divergence` is a set with obsolete revisions,
+    without a successor in destination, that would cause divergence.
     """
-    obsoletenotrebased = {}
-    obsoletewithoutsuccessorindestination = set()
+    obsolete_with_successor_in_destination = {}
+    obsolete_would_cause_divergence = set()
 
     assert repo.filtername is None
     cl = repo.changelog
@@ -2206,21 +2205,24 @@
         succrevs.discard(None)
         if not successors or succrevs.issubset(extinctrevs):
             # no successor, or all successors are extinct
-            obsoletenotrebased[srcrev] = None
+            obsolete_with_successor_in_destination[srcrev] = None
         else:
             dstrev = destmap[srcrev]
             for succrev in succrevs:
                 if cl.isancestorrev(succrev, dstrev):
-                    obsoletenotrebased[srcrev] = succrev
+                    obsolete_with_successor_in_destination[srcrev] = succrev
                     break
             else:
                 # If 'srcrev' has a successor in rebase set but none in
                 # destination (which would be catched above), we shall skip it
                 # and its descendants to avoid divergence.
                 if srcrev in extinctrevs or any(s in destmap for s in succrevs):
-                    obsoletewithoutsuccessorindestination.add(srcrev)
+                    obsolete_would_cause_divergence.add(srcrev)
 
-    return obsoletenotrebased, obsoletewithoutsuccessorindestination
+    return (
+        obsolete_with_successor_in_destination,
+        obsolete_would_cause_divergence,
+    )
 
 
 def abortrebase(ui, repo):



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


More information about the Mercurial-devel mailing list