[PATCH 2 of 2] discovery: prefer loop to double-for list comprehension in changegroupsubset

Kevin Bullock kbullock+mercurial at ringworld.org
Sun Nov 24 17:38:04 CST 2013


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1385336019 21600
#      Sun Nov 24 17:33:39 2013 -0600
# Node ID 40ef143ef1d9749ebf42d3c71170cf2f10f20235
# Parent  4f8e4f2eb8fdfd521d4883d48d9ab6685f64d0a4
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.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -2008,8 +2008,11 @@ class localrepository(object):
             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)
+        #bases = [p for n in bs for p in cl.parents(n) if p != nullid]
+        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)
 


More information about the Mercurial-devel mailing list