discovery: prefer loop to double-for list comprehension in changegroupsubset
authorKevin Bullock <kbullock@ringworld.org>
Sun, 24 Nov 2013 17:33:39 -0600
changeset 20216 01bdccfeb9d9
parent 20215 082b2930fe2c
child 20217 33394f2e331e
discovery: prefer loop to double-for list comprehension in changegroupsubset The double-for form of list comprehensions gets particularly unreadable when you throw in an 'if' condition. This expands the only remaining instance of the double-for syntax in our codebase into a loop.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Jan 02 16:32:51 2014 -0600
+++ b/mercurial/localrepo.py	Sun Nov 24 17:33:39 2013 -0600
@@ -1993,8 +1993,10 @@
             bases = [nullid]
         # TODO: remove call to nodesbetween.
         csets, bases, heads = cl.nodesbetween(bases, heads)
-        bases = [p for n in bases for p in cl.parents(n) if p != nullid]
-        outgoing = discovery.outgoing(cl, bases, heads)
+        discbases = []
+        for n in bases:
+            discbases.extend([p for p in cl.parents(n) if p != nullid])
+        outgoing = discovery.outgoing(cl, discbases, heads)
         bundler = changegroup.bundle10(self)
         return self._changegroupsubset(outgoing, bundler, source)