From patchwork Wed Sep 14 03:11:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5, of, 7, v3, flags] fancyopts: notice default of false and rewrite it to None (API) From: Augie Fackler X-Patchwork-Id: 16618 Message-Id: <944e174886bc83d50e69.1473822681@augie-macbookair2.roam.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Tue, 13 Sep 2016 23:11:21 -0400 # HG changeset patch # User Augie Fackler # Date 1472583470 14400 # Tue Aug 30 14:57:50 2016 -0400 # Node ID 944e174886bc83d50e6995bafa6017c02305aead # Parent 5c886401f3ae369de5cc2583fb46d065ae4d673f fancyopts: notice default of false and rewrite it to None (API) This opens the door to noticing the difference between "flag not specified false" and "explicitly false" in an upcoming patch. Marked as an internal API change since I did have to tweak a couple of spots in our code that were making assumptions about the nature of falseness. diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -92,9 +92,15 @@ def fancyopts(args, options, state, gnu= short, name, default, comment, dummy = option else: short, name, default, comment = option - if default is True and not boolok: - raise ValueError('fancyopts does not support default-true ' - 'boolean flags: %r' % name) + if not boolok: + if default is True: + raise ValueError('fancyopts does not support default-true ' + 'boolean flags: %r' % name) + if default is False: + # So higher layers of hg can identify the difference + # between unspecified and explicitly-false, set this to + # None here. + default = None # convert opts to getopt format oname = name name = name.replace('-', '_')