[PATCH] mq: refactor usage of repo.branchmap().iteritems() with itervalues()

Augie Fackler raf at durin42.com
Thu Sep 26 08:57:14 CDT 2013


On Sep 25, 2013, at 5:49 PM, Kevin Bullock <kbullock+mercurial at ringworld.org> wrote:

> On 25 Sep 2013, at 4:38 PM, Brodie Rao wrote:
> 
>> # HG changeset patch
>> # User Brodie Rao <brodie at sf.io>
>> # Date 1364871676 25200
>> #      Mon Apr 01 20:01:16 2013 -0700
>> # Node ID 5ddfc6e253794f76691b27f805b1275d54708298
>> # Parent  50d721553198cea51c30f53b76d41dc919280097
>> mq: refactor usage of repo.branchmap().iteritems() with itervalues()
>> 
>> diff --git a/hgext/mq.py b/hgext/mq.py
>> --- a/hgext/mq.py
>> +++ b/hgext/mq.py
>> @@ -1222,9 +1222,7 @@ class queue(object):
>>        diffopts = self.diffopts()
>>        wlock = repo.wlock()
>>        try:
>> -            heads = []
>> -            for b, ls in repo.branchmap().iteritems():
>> -                heads += ls
>> +            heads = [h for hs in repo.branchmap().itervalues() for h in hs]
> 
> The double-`for` is really confusing to me here.

Agreed. At /least/ parenthesize the nested generator expression. Or something. This is mq, perf isn't exactly critical.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130926/a4be745a/attachment.html>


More information about the Mercurial-devel mailing list