# HG changeset patch # User Pierre-Yves David # Date 1497699533 -7200 # Node ID c2ca511c4771e6dfdb660f0eb62fbe98bbec187e # Parent 31ab1912678a8262ff57414c57c08dd1ce248ce8 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. diff -r 31ab1912678a -r c2ca511c4771 mercurial/configitems.py --- 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, )