# HG changeset patch # User Boris Feld # Date 1508168487 -7200 # Node ID 85a2db47ad50b72194a8ffe86660fbc6c33bd5db # Parent 84c6b9384d6addd59f9d6d3bab6fda8a4201aecd configitems: adds a developer warning when accessing undeclared configuration Now that all known options are declared, we setup a warning to make sure it will stay this way. We disable the warning in two tests checking other behavior with random options. diff -r 84c6b9384d6a -r 85a2db47ad50 mercurial/configitems.py --- a/mercurial/configitems.py Tue Oct 17 21:15:31 2017 +0200 +++ b/mercurial/configitems.py Mon Oct 16 17:41:27 2017 +0200 @@ -249,6 +249,9 @@ coreconfigitem('devel', 'user.obsmarker', default=None, ) +coreconfigitem('devel', 'warn-config-unknown', + default=None, +) coreconfigitem('diff', 'nodates', default=False, ) diff -r 84c6b9384d6a -r 85a2db47ad50 mercurial/ui.py --- a/mercurial/ui.py Tue Oct 17 21:15:31 2017 +0200 +++ b/mercurial/ui.py Mon Oct 16 17:41:27 2017 +0200 @@ -477,6 +477,10 @@ if item is not None: alternates.extend(item.alias) + else: + msg = ("accessing unregistered config item: '%s.%s'") + msg %= (section, name) + self.develwarn(msg, 2, 'warn-config-unknown') if default is _unset: if item is None: diff -r 84c6b9384d6a -r 85a2db47ad50 tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Tue Oct 17 21:15:31 2017 +0200 +++ b/tests/test-devel-warnings.t Mon Oct 16 17:41:27 2017 +0200 @@ -363,6 +363,8 @@ > repo.ui.config('test', 'some', 'foo') > repo.ui.config('test', 'dynamic', 'some-required-default') > repo.ui.config('test', 'dynamic') + > repo.ui.config('test', 'unregistered') + > repo.ui.config('unregistered', 'unregistered') > EOF $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig @@ -372,5 +374,7 @@ devel-warn: specifying a default value for a registered config item: 'ui.interactive' 'None' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) devel-warn: specifying a default value for a registered config item: 'test.some' 'foo' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) devel-warn: config item requires an explicit default value: 'test.dynamic' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) + devel-warn: accessing unregistered config item: 'test.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) + devel-warn: accessing unregistered config item: 'unregistered.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) $ cd .. diff -r 84c6b9384d6a -r 85a2db47ad50 tests/test-trusted.py --- a/tests/test-trusted.py Tue Oct 17 21:15:31 2017 +0200 +++ b/tests/test-trusted.py Mon Oct 16 17:41:27 2017 +0200 @@ -67,6 +67,13 @@ trusted)) u = uimod.ui.load() + # disable the configuration registration warning + # + # the purpose of this test is to check the old behavior, not to validate the + # behavior from registered item. so we silent warning related to unregisted + # config. + u.setconfig('devel', 'warn-config-unknown', False, 'test') + u.setconfig('devel', 'all-warnings', False, 'test') u.setconfig('ui', 'debug', str(bool(debug))) u.setconfig('ui', 'report_untrusted', str(bool(report))) u.readconfig('.hg/hgrc') @@ -157,6 +164,13 @@ print() print("# read trusted, untrusted, new ui, trusted") u = uimod.ui.load() +# disable the configuration registration warning +# +# the purpose of this test is to check the old behavior, not to validate the +# behavior from registered item. so we silent warning related to unregisted +# config. +u.setconfig('devel', 'warn-config-unknown', False, 'test') +u.setconfig('devel', 'all-warnings', False, 'test') u.setconfig('ui', 'debug', 'on') u.readconfig(filename) u2 = u.copy() diff -r 84c6b9384d6a -r 85a2db47ad50 tests/test-ui-config.py --- a/tests/test-ui-config.py Tue Oct 17 21:15:31 2017 +0200 +++ b/tests/test-ui-config.py Mon Oct 16 17:41:27 2017 +0200 @@ -6,6 +6,15 @@ ) testui = uimod.ui.load() + +# disable the configuration registration warning +# +# the purpose of this test is to check the old behavior, not to validate the +# behavior from registered item. so we silent warning related to unregisted +# config. +testui.setconfig('devel', 'warn-config-unknown', False, 'test') +testui.setconfig('devel', 'all-warnings', False, 'test') + parsed = dispatch._parseconfig(testui, [ 'values.string=string value', 'values.bool1=true',