[PATCH] revset: document the choice made in _generatorset.__iter__

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Sep 17 11:36:34 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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):


More information about the Mercurial-devel mailing list