From patchwork Sun Nov 24 23:38:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2] discovery: prefer loop to double-for list comprehension in changegroupsubset From: Kevin Bullock X-Patchwork-Id: 3119 Message-Id: <40ef143ef1d9749ebf42.1385336284@billings.local> To: mercurial-devel@selenic.com Date: Sun, 24 Nov 2013 17:38:04 -0600 # HG changeset patch # User Kevin Bullock # 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)