rebase: don't update state dict same way for each root
authorMartin von Zweigbergk <martinvonz@google.com>
Sat, 11 Mar 2017 12:25:56 -0800
changeset 32175 456b4a32d75f
parent 32174 e4a4ebfd9d8e
child 32176 cf042543afa2
rebase: don't update state dict same way for each root The update statement does not depend on anything in the loop, so just move it before the loop and do it once. There are no cases where update would happen 0 times before (and 1 now); the function returns early in all such cases.
hgext/rebase.py
--- a/hgext/rebase.py	Thu May 04 21:11:40 2017 -0700
+++ b/hgext/rebase.py	Sat Mar 11 12:25:56 2017 -0800
@@ -1246,7 +1246,7 @@
     if not roots:
         raise error.Abort(_('no matching revisions'))
     roots.sort()
-    state = {}
+    state = dict.fromkeys(rebaseset, revtodo)
     detachset = set()
     for root in roots:
         commonbase = root.ancestor(dest)
@@ -1264,7 +1264,6 @@
                 return None
 
         repo.ui.debug('rebase onto %s starting from %s\n' % (dest, root))
-        state.update(dict.fromkeys(rebaseset, revtodo))
         # Rebase tries to turn <dest> into a parent of <root> while
         # preserving the number of parents of rebased changesets:
         #