Show More
@@ -471,12 +471,16 b' class ui(object):' | |||
|
471 | 471 | return value |
|
472 | 472 | |
|
473 | 473 | def _config(self, section, name, default=_unset, untrusted=False): |
|
474 | value = default | |
|
474 | value = itemdefault = default | |
|
475 | 475 | item = self._knownconfig.get(section, {}).get(name) |
|
476 | 476 | alternates = [(section, name)] |
|
477 | 477 | |
|
478 | 478 | if item is not None: |
|
479 | 479 | alternates.extend(item.alias) |
|
480 | if callable(item.default): | |
|
481 | itemdefault = item.default() | |
|
482 | else: | |
|
483 | itemdefault = item.default | |
|
480 | 484 | else: |
|
481 | 485 | msg = ("accessing unregistered config item: '%s.%s'") |
|
482 | 486 | msg %= (section, name) |
@@ -490,13 +494,12 b' class ui(object):' | |||
|
490 | 494 | msg = "config item requires an explicit default value: '%s.%s'" |
|
491 | 495 | msg %= (section, name) |
|
492 | 496 | self.develwarn(msg, 2, 'warn-config-default') |
|
493 | elif callable(item.default): | |
|
494 | value = item.default() | |
|
495 | 497 | else: |
|
496 |
value = item |
|
|
498 | value = itemdefault | |
|
497 | 499 | elif (item is not None |
|
498 |
and item.default is not configitems.dynamicdefault |
|
|
499 | msg = ("specifying a default value for a registered " | |
|
500 | and item.default is not configitems.dynamicdefault | |
|
501 | and default != itemdefault): | |
|
502 | msg = ("specifying a mismatched default value for a registered " | |
|
500 | 503 | "config item: '%s.%s' '%s'") |
|
501 | 504 | msg %= (section, name, default) |
|
502 | 505 | self.develwarn(msg, 2, 'warn-config-default') |
@@ -352,17 +352,21 b' Test warning on config option access and' | |||
|
352 | 352 | > |
|
353 | 353 | > configitem('test', 'some', default='foo') |
|
354 | 354 | > configitem('test', 'dynamic', default=configitems.dynamicdefault) |
|
355 | > configitem('test', 'callable', default=list) | |
|
355 | 356 | > # overwrite a core config |
|
356 | 357 | > configitem('ui', 'quiet', default=False) |
|
357 | 358 | > configitem('ui', 'interactive', default=None) |
|
358 | 359 | > |
|
359 | 360 | > @command(b'buggyconfig') |
|
360 | 361 | > def cmdbuggyconfig(ui, repo): |
|
361 |
> repo.ui.config('ui', 'quiet', |
|
|
362 |
> repo.ui.config('ui', 'interactive', |
|
|
362 | > repo.ui.config('ui', 'quiet', True) | |
|
363 | > repo.ui.config('ui', 'interactive', False) | |
|
364 | > repo.ui.config('test', 'some', 'bar') | |
|
363 | 365 | > repo.ui.config('test', 'some', 'foo') |
|
364 | 366 | > repo.ui.config('test', 'dynamic', 'some-required-default') |
|
365 | 367 | > repo.ui.config('test', 'dynamic') |
|
368 | > repo.ui.config('test', 'callable', []) | |
|
369 | > repo.ui.config('test', 'callable', 'foo') | |
|
366 | 370 | > repo.ui.config('test', 'unregistered') |
|
367 | 371 | > repo.ui.config('unregistered', 'unregistered') |
|
368 | 372 | > EOF |
@@ -370,10 +374,11 b' Test warning on config option access and' | |||
|
370 | 374 | $ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig |
|
371 | 375 | devel-warn: extension 'buggyconfig' overwrite config item 'ui.interactive' at: */mercurial/extensions.py:* (_loadextra) (glob) |
|
372 | 376 | devel-warn: extension 'buggyconfig' overwrite config item 'ui.quiet' at: */mercurial/extensions.py:* (_loadextra) (glob) |
|
373 |
devel-warn: specifying a default value for a registered config item: 'ui.quiet' ' |
|
|
374 |
devel-warn: specifying a default value for a registered config item: 'ui.interactive' ' |
|
|
375 |
devel-warn: specifying a default value for a registered config item: 'test.some' ' |
|
|
377 | devel-warn: specifying a mismatched default value for a registered config item: 'ui.quiet' 'True' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) | |
|
378 | devel-warn: specifying a mismatched default value for a registered config item: 'ui.interactive' 'False' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) | |
|
379 | devel-warn: specifying a mismatched default value for a registered config item: 'test.some' 'bar' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) | |
|
376 | 380 | devel-warn: config item requires an explicit default value: 'test.dynamic' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) |
|
381 | devel-warn: specifying a mismatched default value for a registered config item: 'test.callable' 'foo' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) | |
|
377 | 382 | devel-warn: accessing unregistered config item: 'test.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) |
|
378 | 383 | devel-warn: accessing unregistered config item: 'unregistered.unregistered' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob) |
|
379 | 384 |
General Comments 0
You need to be logged in to leave comments.
Login now