changeset 33849:3ae2eaecb49e

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
author Jun Wu <quark@fb.com>
date Fri, 11 Aug 2017 01:08:07 -0700
parents bc9e075133c9
children 84a3e04e35b5
files hgext/rebase.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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]