[PATCH] mq: refactor usage of repo.branchmap().iteritems() with itervalues()
Martin Geisler
martin at geisler.net
Thu Sep 26 21:34:40 UTC 2013
Kevin Bullock <kbullock+mercurial at ringworld.org> writes:
> 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.
Yeah, it's a slightly unusual construct.
I would prefer a loop over itervalues (that's a good change) and then
use extend instead +=. I find extend better because it has no return
value and no return value is needed or wanted here.
--
Martin Geisler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20130926/7cdd1f97/attachment.asc>
More information about the Mercurial-devel
mailing list