Mercurial > hg
changeset 32958:4a3f1d362e5f
config: explicitly track the use of the standard default value
We introduce a small object used to detect that no specific default value has
been passed to 'ui.config'. We need this explicit special value since "None" is
a valid and common default value.
The end goal here is to make progress on a centralised and explicit declaration
of the available config option. A first good usecase for this are "default"
value. Before starting looking further down this alley we needs to rework the
handling of default value in the 'ui' object to have all configxyz methods going
through the same logic. This is the first changeset on this trek.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 12:51:11 +0200 |
parents | 067173e3c8a6 |
children | b39dafe681df |
files | mercurial/ui.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Mon Jun 19 22:14:37 2017 -0700 +++ b/mercurial/ui.py Sat Jun 17 12:51:11 2017 +0200 @@ -154,6 +154,10 @@ def _catchterm(*args): raise error.SignalInterrupt +# unique object used to detect no default value has been provided when +# retrieving configuration value. +_unset = object() + class ui(object): def __init__(self, src=None): """Create a fresh new ui object if no src given @@ -432,7 +436,9 @@ def configsource(self, section, name, untrusted=False): return self._data(untrusted).source(section, name) - def config(self, section, name, default=None, untrusted=False): + def config(self, section, name, default=_unset, untrusted=False): + if default is _unset: + default = None if isinstance(name, list): alternates = name else: