Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 32985:28a65fd4b359
configitems: get default values from the central registry when available
We do not have any registered config yet, but we are now ready to use them.
For now we ignore this feature for config access with "alternates". On the long
run, we expect alternates to be handled as "aliases" by the config item
themself.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 12:15:28 +0200 |
parents | 6d983e8af49c |
children | 149b68224b08 |
comparison
equal
deleted
inserted
replaced
32984:6d983e8af49c | 32985:28a65fd4b359 |
---|---|
437 | 437 |
438 def configsource(self, section, name, untrusted=False): | 438 def configsource(self, section, name, untrusted=False): |
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 if default is _unset: | |
443 default = None | |
444 if isinstance(name, list): | 442 if isinstance(name, list): |
445 alternates = name | 443 alternates = name |
444 # let us ignore the config items in the alternates case for now | |
445 if default is _unset: | |
446 default = None | |
446 else: | 447 else: |
448 if default is _unset: | |
449 default = None | |
450 item = self._knownconfig.get(section, {}).get(name) | |
451 if item is not None: | |
452 default = item.default | |
447 alternates = [name] | 453 alternates = [name] |
448 | 454 |
449 for n in alternates: | 455 for n in alternates: |
450 value = self._data(untrusted).get(section, n, None) | 456 value = self._data(untrusted).get(section, n, None) |
451 if value is not None: | 457 if value is not None: |