##// END OF EJS Templates
config: extract the core config logic into a private method...
marmoute -
r33058:1aa05203 default
parent child Browse files
Show More
@@ -439,32 +439,38 b' class ui(object):'
439 439 return self._data(untrusted).source(section, name)
440 440
441 441 def config(self, section, name, default=_unset, untrusted=False):
442 """return the plain string version of a config"""
443 value = self._config(section, name, default=default,
444 untrusted=untrusted)
445 if value is _unset:
446 return None
447 return value
448
449 def _config(self, section, name, default=_unset, untrusted=False):
450 value = default
442 451 if isinstance(name, list):
443 452 alternates = name
444 # let us ignore the config items in the alternates case for now
445 if default is _unset:
446 default = None
447 453 else:
448 454 item = self._knownconfig.get(section, {}).get(name)
449 455 if default is _unset:
450 default = None
451 if item is not None:
452 default = item.default
456 if item is None:
457 value = default
458 else:
459 value = item.default
453 460 elif item is not None:
454 461 msg = ("specifying a default value for a registered "
455 462 "config item: '%s.%s' '%s'")
456 463 msg %= (section, name, default)
457 self.develwarn(msg, 1, 'warn-config-default')
464 self.develwarn(msg, 2, 'warn-config-default')
458 465
459 466 alternates = [name]
460 467
461 468 for n in alternates:
462 value = self._data(untrusted).get(section, n, None)
463 if value is not None:
469 candidate = self._data(untrusted).get(section, n, None)
470 if candidate is not None:
471 value = candidate
464 472 name = n
465 473 break
466 else:
467 value = default
468 474
469 475 if self.debugflag and not untrusted and self._reportuntrusted:
470 476 for n in alternates:
General Comments 0
You need to be logged in to leave comments. Login now