##// END OF EJS Templates
configitems: adds a developer warning when accessing undeclared configuration...
Boris Feld -
r34859:85a2db47 default
parent child Browse files
Show More
@@ -249,6 +249,9 b" coreconfigitem('devel', 'warn-config-def"
249 coreconfigitem('devel', 'user.obsmarker',
249 coreconfigitem('devel', 'user.obsmarker',
250 default=None,
250 default=None,
251 )
251 )
252 coreconfigitem('devel', 'warn-config-unknown',
253 default=None,
254 )
252 coreconfigitem('diff', 'nodates',
255 coreconfigitem('diff', 'nodates',
253 default=False,
256 default=False,
254 )
257 )
@@ -477,6 +477,10 b' class ui(object):'
477
477
478 if item is not None:
478 if item is not None:
479 alternates.extend(item.alias)
479 alternates.extend(item.alias)
480 else:
481 msg = ("accessing unregistered config item: '%s.%s'")
482 msg %= (section, name)
483 self.develwarn(msg, 2, 'warn-config-unknown')
480
484
481 if default is _unset:
485 if default is _unset:
482 if item is None:
486 if item is None:
@@ -363,6 +363,8 b' Test warning on config option access and'
363 > repo.ui.config('test', 'some', 'foo')
363 > repo.ui.config('test', 'some', 'foo')
364 > repo.ui.config('test', 'dynamic', 'some-required-default')
364 > repo.ui.config('test', 'dynamic', 'some-required-default')
365 > repo.ui.config('test', 'dynamic')
365 > repo.ui.config('test', 'dynamic')
366 > repo.ui.config('test', 'unregistered')
367 > repo.ui.config('unregistered', 'unregistered')
366 > EOF
368 > EOF
367
369
368 $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig
370 $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig
@@ -372,5 +374,7 b' Test warning on config option access and'
372 devel-warn: specifying a default value for a registered config item: 'ui.interactive' 'None' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
374 devel-warn: specifying a default value for a registered config item: 'ui.interactive' 'None' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
373 devel-warn: specifying a default value for a registered config item: 'test.some' 'foo' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
375 devel-warn: specifying a default value for a registered config item: 'test.some' 'foo' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
374 devel-warn: config item requires an explicit default value: 'test.dynamic' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
376 devel-warn: config item requires an explicit default value: 'test.dynamic' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
377 devel-warn: accessing unregistered config item: 'test.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
378 devel-warn: accessing unregistered config item: 'unregistered.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
375
379
376 $ cd ..
380 $ cd ..
@@ -67,6 +67,13 b" def testui(user='foo', group='bar', tuse"
67 trusted))
67 trusted))
68
68
69 u = uimod.ui.load()
69 u = uimod.ui.load()
70 # disable the configuration registration warning
71 #
72 # the purpose of this test is to check the old behavior, not to validate the
73 # behavior from registered item. so we silent warning related to unregisted
74 # config.
75 u.setconfig('devel', 'warn-config-unknown', False, 'test')
76 u.setconfig('devel', 'all-warnings', False, 'test')
70 u.setconfig('ui', 'debug', str(bool(debug)))
77 u.setconfig('ui', 'debug', str(bool(debug)))
71 u.setconfig('ui', 'report_untrusted', str(bool(report)))
78 u.setconfig('ui', 'report_untrusted', str(bool(report)))
72 u.readconfig('.hg/hgrc')
79 u.readconfig('.hg/hgrc')
@@ -157,6 +164,13 b" print(u.config('foobar', 'baz'))"
157 print()
164 print()
158 print("# read trusted, untrusted, new ui, trusted")
165 print("# read trusted, untrusted, new ui, trusted")
159 u = uimod.ui.load()
166 u = uimod.ui.load()
167 # disable the configuration registration warning
168 #
169 # the purpose of this test is to check the old behavior, not to validate the
170 # behavior from registered item. so we silent warning related to unregisted
171 # config.
172 u.setconfig('devel', 'warn-config-unknown', False, 'test')
173 u.setconfig('devel', 'all-warnings', False, 'test')
160 u.setconfig('ui', 'debug', 'on')
174 u.setconfig('ui', 'debug', 'on')
161 u.readconfig(filename)
175 u.readconfig(filename)
162 u2 = u.copy()
176 u2 = u.copy()
@@ -6,6 +6,15 b' from mercurial import ('
6 )
6 )
7
7
8 testui = uimod.ui.load()
8 testui = uimod.ui.load()
9
10 # disable the configuration registration warning
11 #
12 # the purpose of this test is to check the old behavior, not to validate the
13 # behavior from registered item. so we silent warning related to unregisted
14 # config.
15 testui.setconfig('devel', 'warn-config-unknown', False, 'test')
16 testui.setconfig('devel', 'all-warnings', False, 'test')
17
9 parsed = dispatch._parseconfig(testui, [
18 parsed = dispatch._parseconfig(testui, [
10 'values.string=string value',
19 'values.string=string value',
11 'values.bool1=true',
20 'values.bool1=true',
General Comments 0
You need to be logged in to leave comments. Login now