Mercurial > hg
changeset 33131:c2ca511c4771
configitems: extract the logic to build a registrar on any configtable
Having the logic available independently from the mapping used is a necessary
step toward extensions support.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 13:38:53 +0200 |
parents | 31ab1912678a |
children | c467d13334ee |
files | mercurial/configitems.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/configitems.py Mon Jun 19 01:08:11 2017 +0200 +++ b/mercurial/configitems.py Sat Jun 17 13:38:53 2017 +0200 @@ -7,6 +7,8 @@ from __future__ import absolute_import +import functools + from . import ( error, ) @@ -26,9 +28,9 @@ coreitems = {} -def coreconfigitem(*args, **kwargs): +def _register(configtable, *args, **kwargs): item = configitem(*args, **kwargs) - section = coreitems.setdefault(item.section, {}) + section = configtable.setdefault(item.section, {}) if item.name in section: msg = "duplicated config item registration for '%s.%s'" raise error.ProgrammingError(msg % (item.section, item.name)) @@ -36,6 +38,11 @@ # Registering actual config items +def getitemregister(configtable): + return functools.partial(_register, configtable) + +coreconfigitem = getitemregister(coreitems) + coreconfigitem('patch', 'fuzz', default=2, )