diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -445,11 +445,17 @@ class ui(object): if default is _unset: default = None else: + item = self._knownconfig.get(section, {}).get(name) if default is _unset: default = None - item = self._knownconfig.get(section, {}).get(name) if item is not None: default = item.default + elif item is not None: + msg = ("specifying a default value for a registered " + "config item: '%s.%s' '%s'") + msg %= (section, name, default) + self.develwarn(msg, 1, 'warn-config-default') + alternates = [name] for n in alternates: diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t +++ b/tests/test-devel-warnings.t @@ -193,4 +193,23 @@ Old style deprecation warning $ HGEMITWARNINGS= hg nouiwarning +Test warning on config option access and registration + + $ cat << EOF > ${TESTTMP}/buggyconfig.py + > """A small extension that tests our developer warnings for config""" + > + > from mercurial import registrar + > + > cmdtable = {} + > command = registrar.command(cmdtable) + > + > @command('buggyconfig') + > def cmdbuggyconfig(ui, repo): + > repo.ui.config('ui', 'quiet', False) + > repo.ui.config('ui', 'interactive', None) + > EOF + + $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig + devel-warn: specifying a default value for a registered config item: 'ui.quiet' 'False' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) + $ cd ..