Mercurial > public > mercurial-scm > hg
diff mercurial/ui.py @ 34947:ff2110eadbfa stable
configitems: relax warning about unwanted default value
The original condition was a bit harsh for extension authors since third-party
extensions need to preserve compatibility with older Mercurial versions, where
no defaults would be loaded from the configtable. So let's silence the warning
if the given default value matches, which should be harmless.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 31 Oct 2017 22:37:30 +0900 |
parents | e9f320a40b44 |
children | 58e7791e243b c9740b69b9b7 |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Oct 26 11:07:06 2017 -0700 +++ b/mercurial/ui.py Tue Oct 31 22:37:30 2017 +0900 @@ -471,12 +471,16 @@ return value def _config(self, section, name, default=_unset, untrusted=False): - value = default + value = itemdefault = default item = self._knownconfig.get(section, {}).get(name) alternates = [(section, name)] if item is not None: alternates.extend(item.alias) + if callable(item.default): + itemdefault = item.default() + else: + itemdefault = item.default else: msg = ("accessing unregistered config item: '%s.%s'") msg %= (section, name) @@ -490,13 +494,12 @@ msg = "config item requires an explicit default value: '%s.%s'" msg %= (section, name) self.develwarn(msg, 2, 'warn-config-default') - elif callable(item.default): - value = item.default() else: - value = item.default + value = itemdefault elif (item is not None - and item.default is not configitems.dynamicdefault): - msg = ("specifying a default value for a registered " + and item.default is not configitems.dynamicdefault + and default != itemdefault): + msg = ("specifying a mismatched default value for a registered " "config item: '%s.%s' '%s'") msg %= (section, name, default) self.develwarn(msg, 2, 'warn-config-default')