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
--- 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]