Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 32989:149b68224b08
configitems: issue a devel warning when overriding default config
If the option is registered, there is already a default value available and
passing a new one is at best redundant. So we issue a deprecation warning in
this case.
(note: there will be case were the default value will not be as simple as what
is currently possible. We'll upgrade the configitems code to handle them in
time.)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 13:08:03 +0200 |
parents | 28a65fd4b359 |
children | 1aa05203f7f6 |
comparison
equal
deleted
inserted
replaced
32986:2529e2ae9f4c | 32989:149b68224b08 |
---|---|
443 alternates = name | 443 alternates = name |
444 # let us ignore the config items in the alternates case for now | 444 # let us ignore the config items in the alternates case for now |
445 if default is _unset: | 445 if default is _unset: |
446 default = None | 446 default = None |
447 else: | 447 else: |
448 item = self._knownconfig.get(section, {}).get(name) | |
448 if default is _unset: | 449 if default is _unset: |
449 default = None | 450 default = None |
450 item = self._knownconfig.get(section, {}).get(name) | |
451 if item is not None: | 451 if item is not None: |
452 default = item.default | 452 default = item.default |
453 elif item is not None: | |
454 msg = ("specifying a default value for a registered " | |
455 "config item: '%s.%s' '%s'") | |
456 msg %= (section, name, default) | |
457 self.develwarn(msg, 1, 'warn-config-default') | |
458 | |
453 alternates = [name] | 459 alternates = [name] |
454 | 460 |
455 for n in alternates: | 461 for n in alternates: |
456 value = self._data(untrusted).get(section, n, None) | 462 value = self._data(untrusted).get(section, n, None) |
457 if value is not None: | 463 if value is not None: |