D2811: rebase: move constant expressions out of inner loop in _performrebase()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

D2811: rebase: move constant expressions out of inner loop in _performrebase()

indygreg (Gregory Szorc)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

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



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D2811: rebase: move constant expressions out of inner loop in _performrebase()

indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG41d6df958331: rebase: move constant expressions out of inner loop in _performrebase() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2811?vs=6876&id=6990

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

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



To: martinvonz, #hg-reviewers, yuja
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel