Patchwork revset: document the choice made in _generatorset.__iter__

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 17, 2014, 4:36 p.m.
Message ID <e282c07bac1a5627920f.1410971794@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5851/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 17, 2014, 4:36 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1410936161 25200
#      Tue Sep 16 23:42:41 2014 -0700
# Node ID e282c07bac1a5627920f53bd8b233a55ce42d05d
# Parent  a476ee0b8e799c1b9b82ad2db350c90a31274879
revset: document the choice made in _generatorset.__iter__

The method code looks a bit ugly but have good reason to do so. We document them
to prevent naive refactoring in the future.
Durham Goode - Sept. 19, 2014, 10:24 p.m.
On 9/17/14, 9:36 AM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1410936161 25200
> #      Tue Sep 16 23:42:41 2014 -0700
> # Node ID e282c07bac1a5627920f53bd8b233a55ce42d05d
> # Parent  a476ee0b8e799c1b9b82ad2db350c90a31274879
> revset: document the choice made in _generatorset.__iter__
>
> The method code looks a bit ugly but have good reason to do so. We document them
> to prevent naive refactoring in the future.
>
Queued to clowncopter.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2646,10 +2646,16 @@  class _generatorset(object):
         if self._finished:
             for x in self._genlist:
                 yield x
             return
 
+        # we have to use this complexe iteration strategy to allow multiple
+        # iteration at the same time. We need to be able to catch revision
+        # removed from `consumegen` and added to genlist in another instance.
+        #
+        # Getting ride of it would provide an about 15% speed up on this
+        # iteration.
         i = 0
         genlist = self._genlist
         consume = self._consumegen()
         while True:
             if i < len(genlist):