Show More
@@ -133,6 +133,14 b' def _validatecmdtable(ui, cmdtable):' | |||||
133 | "registrar.command to register '%s'" % c, '4.6') |
|
133 | "registrar.command to register '%s'" % c, '4.6') | |
134 | missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] |
|
134 | missing = [a for a in _cmdfuncattrs if not util.safehasattr(f, a)] | |
135 | if not missing: |
|
135 | if not missing: | |
|
136 | for option in e[1]: | |||
|
137 | default = option[2] | |||
|
138 | if isinstance(default, type(u'')): | |||
|
139 | raise error.ProgrammingError( | |||
|
140 | "option '%s.%s' has a unicode default value" | |||
|
141 | % (c, option[1]), | |||
|
142 | hint=("change the %s.%s default value to a " | |||
|
143 | "non-unicode string" % (c, option[1]))) | |||
136 | continue |
|
144 | continue | |
137 | raise error.ProgrammingError( |
|
145 | raise error.ProgrammingError( | |
138 | 'missing attributes: %s' % ', '.join(missing), |
|
146 | 'missing attributes: %s' % ', '.join(missing), |
@@ -1709,3 +1709,26 b' Show deprecation warning for the use of ' | |||||
1709 | $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null |
|
1709 | $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null | |
1710 | devel-warn: cmdutil.command is deprecated, use registrar.command to register 'foo' |
|
1710 | devel-warn: cmdutil.command is deprecated, use registrar.command to register 'foo' | |
1711 | (compatibility will be dropped after Mercurial-4.6, update your code.) * (glob) |
|
1711 | (compatibility will be dropped after Mercurial-4.6, update your code.) * (glob) | |
|
1712 | ||||
|
1713 | Prohibit the use of unicode strings as the default value of options | |||
|
1714 | ||||
|
1715 | $ hg init $TESTTMP/opt-unicode-default | |||
|
1716 | ||||
|
1717 | $ cat > $TESTTMP/test_unicode_default_value.py << EOF | |||
|
1718 | > from mercurial import registrar | |||
|
1719 | > cmdtable = {} | |||
|
1720 | > command = registrar.command(cmdtable) | |||
|
1721 | > @command('dummy', [('', 'opt', u'value', u'help')], 'ext [OPTIONS]') | |||
|
1722 | > def ext(*args, **opts): | |||
|
1723 | > print(opts['opt']) | |||
|
1724 | > EOF | |||
|
1725 | $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF | |||
|
1726 | > [extensions] | |||
|
1727 | > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py | |||
|
1728 | > EOF | |||
|
1729 | $ hg -R $TESTTMP/opt-unicode-default dummy | |||
|
1730 | *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: option 'dummy.opt' has a unicode default value | |||
|
1731 | *** (change the dummy.opt default value to a non-unicode string) | |||
|
1732 | hg: unknown command 'dummy' | |||
|
1733 | (did you mean summary?) | |||
|
1734 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now