# HG changeset patch # User Pierre-Yves David # Date 1497717807 -7200 # Node ID 6d983e8af49c391d464a0267395bf44267488e5a # Parent 0d757af1ea67894cc84d5b3cd36f9fd2c710180c configitems: introduce a central registry for config option We now have the appropriate infrastructure to register config items. Usage will added in the next changeset. diff -r 0d757af1ea67 -r 6d983e8af49c mercurial/configitems.py --- a/mercurial/configitems.py Sat Jun 17 18:41:55 2017 +0200 +++ b/mercurial/configitems.py Sat Jun 17 18:43:27 2017 +0200 @@ -7,6 +7,10 @@ from __future__ import absolute_import +from . import ( + error, +) + class configitem(object): """represent a known config item @@ -19,3 +23,13 @@ self.section = section self.name = name self.default = default + +coreitems = {} + +def coreconfigitem(*args, **kwargs): + item = configitem(*args, **kwargs) + section = coreitems.setdefault(item.section, {}) + if item.name in section: + msg = "duplicated config item registration for '%s.%s'" + raise error.ProgrammingError(msg % (item.section, item.name)) + section[item.name] = item diff -r 0d757af1ea67 -r 6d983e8af49c mercurial/ui.py --- a/mercurial/ui.py Sat Jun 17 18:41:55 2017 +0200 +++ b/mercurial/ui.py Sat Jun 17 18:43:27 2017 +0200 @@ -27,6 +27,7 @@ from . import ( color, config, + configitems, encoding, error, formatter, @@ -178,6 +179,7 @@ self._bufferapplylabels = None self.quiet = self.verbose = self.debugflag = self.tracebackflag = False self._reportuntrusted = True + self._knownconfig = configitems.coreitems self._ocfg = config.config() # overlay self._tcfg = config.config() # trusted self._ucfg = config.config() # untrusted