[PATCH 4 of 8 v2] commands: stop abusing int-ness of Python booleans
Augie Fackler
raf at durin42.com
Wed Aug 31 17:20:23 EDT 2016
> On Aug 31, 2016, at 17:19, Kevin Bullock <kbullock+mercurial at ringworld.org> wrote:
>
>> On Aug 30, 2016, at 15:16, Augie Fackler <raf at durin42.com> wrote:
>>
>> # HG changeset patch
>> # User Augie Fackler <augie at google.com>
>> # Date 1472586452 14400
>> # Tue Aug 30 15:47:32 2016 -0400
>> # Node ID c65c0181a9885d3c95e808272c2f609c3a9c8749
>> # Parent 69d84366fa224f5dedfdd18a9f5e2413060a8121
>> commands: stop abusing int-ness of Python booleans
>>
>> This will break as soon as fancyopts starts returning None for all
>> unspecified boolean flags.
>>
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -896,7 +896,8 @@ def bisect(ui, repo, rev=None, extra=Non
>> bad = True
>> else:
>> reset = True
>> - elif extra or good + bad + skip + reset + extend + bool(command) > 1:
>> + elif extra or sum(1 for b in (good, bad, skip,
>> + reset, extend, command) if b) > 1:
>
> Couldn't we stop abusing math for this at all using any()?
>
> elif extra or any((good, bad, skip, reset, extend, command)):
>
> Docs say it was added in Python 2.5.
No, because we care if *more than one* of the bools was true. I originally had the same idea though.
>
> pacem in terris / мир / शान्ति / سَلاَم / 平和
> Kevin R. Bullock
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list