changeset 38672:0f8599afb92f

rebase: avoid converting from nodes to revnums twice 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. Differential Revision: https://phab.mercurial-scm.org/D3941
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 11 Jul 2018 15:01:47 -0700
parents 99ed6e2f6606
children 20a30bb8f276
files hgext/rebase.py
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Jul 11 15:03:39 2018 -0700
+++ b/hgext/rebase.py	Wed Jul 11 15:01:47 2018 -0700
@@ -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 (