Re: [PATCH 4 of 8 v2] commands: stop abusing int-ness of Python booleans

2016-09-01 Thread timeless
Can we change ">1" to ">=2" to make this clearer?

On Aug 31, 2016 5:33 PM, "Augie Fackler"  wrote:

>
> > On Aug 31, 2016, at 17:19, Kevin Bullock  org> wrote:
> >
> >> On Aug 30, 2016, at 15:16, Augie Fackler  wrote:
> >>
> >> # HG changeset patch
> >> # User Augie Fackler 
> >> # 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@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 8 v2] commands: stop abusing int-ness of Python booleans

2016-08-31 Thread Augie Fackler

> On Aug 31, 2016, at 17:19, Kevin Bullock  
> wrote:
> 
>> On Aug 30, 2016, at 15:16, Augie Fackler  wrote:
>> 
>> # HG changeset patch
>> # User Augie Fackler 
>> # 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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel