Patchwork [1,of,3] rebase: don't update state dict same way for each root

login
register
mail settings
Submitter via Mercurial-devel
Date May 4, 2017, 8:20 p.m.
Message ID <5af88edb7a0bbafad999.1493929210@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20435/
State Accepted
Headers show

Comments

via Mercurial-devel - May 4, 2017, 8:20 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1489263956 28800
#      Sat Mar 11 12:25:56 2017 -0800
# Node ID 5af88edb7a0bbafad999a2cef8968efbfd64becf
# Parent  efcaf6ab86f40b8cc6fbb0e28764d9c1e88dfb27
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.
Yuya Nishihara - May 6, 2017, 2:20 a.m.
On Thu, 04 May 2017 13:20:10 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1489263956 28800
> #      Sat Mar 11 12:25:56 2017 -0800
> # Node ID 5af88edb7a0bbafad999a2cef8968efbfd64becf
> # Parent  efcaf6ab86f40b8cc6fbb0e28764d9c1e88dfb27
> rebase: don't update state dict same way for each root

I've queued this bit, thanks.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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:
         #