rebase: optimize "source" calculation in adjustdest
authorJun Wu <quark@fb.com>
Fri, 11 Aug 2017 01:08:07 -0700
changeset 33849 3ae2eaecb49e
parent 33848 bc9e075133c9
child 33850 84a3e04e35b5
rebase: optimize "source" calculation in adjustdest The "source" variable is calculated inside a loop but it does not depend on loop variables. Therefore move it outside the loop. Differential Revision: https://phab.mercurial-scm.org/D345
hgext/rebase.py
--- a/hgext/rebase.py	Fri Aug 11 01:36:59 2017 -0700
+++ b/hgext/rebase.py	Fri Aug 11 01:08:07 2017 -0700
@@ -916,12 +916,13 @@
         |/          |/
         A           A
     """
+    # pick already rebased revs from state
+    source = [s for s, d in state.items() if d > 0]
+
     result = []
     for prev in repo.changelog.parentrevs(rev):
         adjusted = dest
         if prev != nullrev:
-            # pick already rebased revs from state
-            source = [s for s, d in state.items() if d > 0]
             candidate = repo.revs('max(%ld and (::%d))', source, prev).first()
             if candidate is not None:
                 adjusted = state[candidate]