##// 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 return self._data(untrusted).source(section, name)
439 return self._data(untrusted).source(section, name)
440
440
441 def config(self, section, name, default=_unset, untrusted=False):
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 if isinstance(name, list):
451 if isinstance(name, list):
443 alternates = name
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 else:
453 else:
448 item = self._knownconfig.get(section, {}).get(name)
454 item = self._knownconfig.get(section, {}).get(name)
449 if default is _unset:
455 if default is _unset:
450 default = None
456 if item is None:
451 if item is not None:
457 value = default
452 default = item.default
458 else:
459 value = item.default
453 elif item is not None:
460 elif item is not None:
454 msg = ("specifying a default value for a registered "
461 msg = ("specifying a default value for a registered "
455 "config item: '%s.%s' '%s'")
462 "config item: '%s.%s' '%s'")
456 msg %= (section, name, default)
463 msg %= (section, name, default)
457 self.develwarn(msg, 1, 'warn-config-default')
464 self.develwarn(msg, 2, 'warn-config-default')
458
465
459 alternates = [name]
466 alternates = [name]
460
467
461 for n in alternates:
468 for n in alternates:
462 value = self._data(untrusted).get(section, n, None)
469 candidate = self._data(untrusted).get(section, n, None)
463 if value is not None:
470 if candidate is not None:
471 value = candidate
464 name = n
472 name = n
465 break
473 break
466 else:
467 value = default
468
474
469 if self.debugflag and not untrusted and self._reportuntrusted:
475 if self.debugflag and not untrusted and self._reportuntrusted:
470 for n in alternates:
476 for n in alternates:
General Comments 0
You need to be logged in to leave comments. Login now