Patchwork [4,of,7,v3,flags] commands: stop abusing int-ness of Python booleans

login
register
mail settings
Submitter Augie Fackler
Date Sept. 14, 2016, 3:11 a.m.
Message ID <5c886401f3ae369de5cc.1473822680@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/16617/
State Changes Requested
Headers show

Comments

Augie Fackler - Sept. 14, 2016, 3:11 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1472586452 14400
#      Tue Aug 30 15:47:32 2016 -0400
# Node ID 5c886401f3ae369de5cc2583fb46d065ae4d673f
# Parent  b9c309d911c7088a48a8ed25235f5365c649017b
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)