changeset 36933:61600b024a70

rebase: move constant expressions out of inner loop in _performrebase() Differential Revision: https://phab.mercurial-scm.org/D2811
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 04 Mar 2018 09:07:06 -0800
parents 437f80436186
children dbae581010ea
files hgext/rebase.py
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Fri Mar 02 15:38:20 2018 -0800
+++ b/hgext/rebase.py	Sun Mar 04 09:07:06 2018 -0800
@@ -423,26 +423,24 @@
 
         cands = [k for k, v in self.state.iteritems() if v == revtodo]
         total = len(cands)
-        pos = 0
+        posholder = [0]
+        def progress(ctx):
+            posholder[0] += 1
+            self.repo.ui.progress(_("rebasing"), posholder[0],
+                                  ("%d:%s" % (ctx.rev(), ctx)),
+                                  _('changesets'), total)
+        allowdivergence = self.ui.configbool(
+            'experimental', 'evolution.allowdivergence')
         for subset in sortsource(self.destmap):
             sortedrevs = self.repo.revs('sort(%ld, -topo)', subset)
-            allowdivergence = self.ui.configbool(
-                'experimental', 'evolution.allowdivergence')
             if not allowdivergence:
                 sortedrevs -= self.repo.revs(
                     'descendants(%ld) and not %ld',
                     self.obsoletewithoutsuccessorindestination,
                     self.obsoletewithoutsuccessorindestination,
                 )
-            posholder = [pos]
-            def progress(ctx):
-                posholder[0] += 1
-                self.repo.ui.progress(_("rebasing"), posholder[0],
-                                      ("%d:%s" % (ctx.rev(), ctx)),
-                                      _('changesets'), total)
             for rev in sortedrevs:
                 self._rebasenode(tr, rev, allowdivergence, progress)
-            pos = posholder[0]
         ui.progress(_('rebasing'), None)
         ui.note(_('rebase merging completed\n'))