Show More
@@ -16,7 +16,15 b' from . import (' | |||
|
16 | 16 | def loadconfigtable(ui, extname, configtable): |
|
17 | 17 | """update config item known to the ui with the extension ones""" |
|
18 | 18 | for section, items in configtable.items(): |
|
19 |
ui._knownconfig.setdefault(section, {}) |
|
|
19 | knownitems = ui._knownconfig.setdefault(section, {}) | |
|
20 | knownkeys = set(knownitems) | |
|
21 | newkeys = set(items) | |
|
22 | for key in sorted(knownkeys & newkeys): | |
|
23 | msg = "extension '%s' overwrite config item '%s.%s'" | |
|
24 | msg %= (extname, section, key) | |
|
25 | ui.develwarn(msg, config='warn-config') | |
|
26 | ||
|
27 | knownitems.update(items) | |
|
20 | 28 | |
|
21 | 29 | class configitem(object): |
|
22 | 30 | """represent a known config item |
@@ -203,14 +203,26 b' Test warning on config option access and' | |||
|
203 | 203 | > cmdtable = {} |
|
204 | 204 | > command = registrar.command(cmdtable) |
|
205 | 205 | > |
|
206 | > configtable = {} | |
|
207 | > configitem = registrar.configitem(configtable) | |
|
208 | > | |
|
209 | > configitem('test', 'some', default='foo') | |
|
210 | > # overwrite a core config | |
|
211 | > configitem('ui', 'quiet', default=False) | |
|
212 | > configitem('ui', 'interactive', default=None) | |
|
213 | > | |
|
206 | 214 | > @command(b'buggyconfig') |
|
207 | 215 | > def cmdbuggyconfig(ui, repo): |
|
208 | 216 | > repo.ui.config('ui', 'quiet', False) |
|
209 | 217 | > repo.ui.config('ui', 'interactive', None) |
|
218 | > repo.ui.config('test', 'some', 'foo') | |
|
210 | 219 | > EOF |
|
211 | 220 | |
|
212 | 221 | $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig |
|
222 | devel-warn: extension 'buggyconfig' overwrite config item 'ui.interactive' at: */mercurial/extensions.py:* (loadall) (glob) | |
|
223 | devel-warn: extension 'buggyconfig' overwrite config item 'ui.quiet' at: */mercurial/extensions.py:* (loadall) (glob) | |
|
213 | 224 | devel-warn: specifying a default value for a registered config item: 'ui.quiet' 'False' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) |
|
214 | 225 | devel-warn: specifying a default value for a registered config item: 'ui.interactive' 'None' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) |
|
226 | devel-warn: specifying a default value for a registered config item: 'test.some' 'foo' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) | |
|
215 | 227 | |
|
216 | 228 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now