Patchwork [4,of,8,v2] commands: stop abusing int-ness of Python booleans

login
register
mail settings
Submitter Augie Fackler
Date Aug. 30, 2016, 8:16 p.m.
Message ID <c65c0181a9885d3c95e8.1472588177@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/16490/
State Changes Requested
Headers show

Comments

Augie Fackler - Aug. 30, 2016, 8:16 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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:
         raise error.Abort(_('incompatible arguments'))
 
     cmdutil.checkunfinished(repo)