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

Augie Fackler raf at durin42.com
Tue Sep 13 23:11:20 EDT 2016


# HG changeset patch
# User Augie Fackler <augie at 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.

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)


More information about the Mercurial-devel mailing list