comparison mercurial/help.py @ 37092:ef6215df2402

fancyopts: prevent mutation of the default value in customopts Differential Revision: https://phab.mercurial-scm.org/D2937
author Daniel Ploch <dploch@google.com>
date Fri, 23 Mar 2018 11:20:49 -0700
parents 979c8ce9022d
children 6890b7e991a4
comparison
equal deleted inserted replaced
37091:979c8ce9022d 37092:ef6215df2402
85 if shortopt: 85 if shortopt:
86 so = '-' + shortopt 86 so = '-' + shortopt
87 lo = '--' + longopt 87 lo = '--' + longopt
88 88
89 if isinstance(default, fancyopts.customopt): 89 if isinstance(default, fancyopts.customopt):
90 default = default.defaultvalue 90 default = default.getdefaultvalue()
91 if default and not callable(default): 91 if default and not callable(default):
92 # default is of unknown type, and in Python 2 we abused 92 # default is of unknown type, and in Python 2 we abused
93 # the %s-shows-repr property to handle integers etc. To 93 # the %s-shows-repr property to handle integers etc. To
94 # match that behavior on Python 3, we do str(default) and 94 # match that behavior on Python 3, we do str(default) and
95 # then convert it to bytes. 95 # then convert it to bytes.