D3941: rebase: avoid converting from nodes to revnums twice

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jul 12 19:34:49 UTC 2018


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

REVISION SUMMARY
  In the case where the node has successors, but none of them is an
  ancestor of the destination, we would iterate over the successor nodes
  twice, check if they're in the repo and convert them to revnums. I
  doubt it's a measureable cost, but it gets simpler this way too.

REPOSITORY
  rHG Mercurial

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

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
@@ -1869,19 +1869,17 @@
             # no successor
             obsoletenotrebased[srcrev] = None
         else:
-            destnode = cl.node(destmap[srcrev])
-            for succnode in successors:
-                if succnode not in nodemap:
-                    continue
-                if cl.isancestor(succnode, destnode):
-                    obsoletenotrebased[srcrev] = nodemap[succnode]
+            dstrev = destmap[srcrev]
+            succrevs = [nodemap[s] for s in successors if s in nodemap]
+            for succrev in succrevs:
+                if cl.isancestorrev(succrev, dstrev):
+                    obsoletenotrebased[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 any(nodemap[s] in destmap for s in successors
-                       if s in nodemap):
+                if any(s in destmap for s in succrevs):
                     obsoletewithoutsuccessorindestination.add(srcrev)
 
     return (



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


More information about the Mercurial-devel mailing list