Patchwork D345: rebase: optimize "source" calculation in adjustdest

login
register
mail settings
Submitter phabricator
Date Aug. 11, 2017, 9:02 a.m.
Message ID <differential-rev-PHID-DREV-slwaanfu53xanldgrarv-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/22866/
State Superseded
Headers show

Comments

phabricator - Aug. 11, 2017, 9:02 a.m.
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The "source" variable is calculated inside a loop but it does not depend on
  loop variables. Therefore move it outside the loop.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D345

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

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