Mercurial > public > mercurial-scm > hg-stable
view mercurial/configitems.py @ 33164:cb7140e230c8
config: register the 'devel.all-warnings' config
Let us start registering the existing option. I'm starting with the 'devel'
section because it is full of useful things that are poorly documented. So
registering these will more than other section.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 28 Jun 2017 13:19:40 +0200 |
parents | 77e666f943a6 |
children | 0224820688ac |
line wrap: on
line source
# configitems.py - centralized declaration of configuration option # # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from __future__ import absolute_import import functools from . import ( error, ) def loadconfigtable(ui, extname, configtable): """update config item known to the ui with the extension ones""" for section, items in configtable.items(): knownitems = ui._knownconfig.setdefault(section, {}) knownkeys = set(knownitems) newkeys = set(items) for key in sorted(knownkeys & newkeys): msg = "extension '%s' overwrite config item '%s.%s'" msg %= (extname, section, key) ui.develwarn(msg, config='warn-config') knownitems.update(items) class configitem(object): """represent a known config item :section: the official config section where to find this item, :name: the official name within the section, :default: default value for this item, """ def __init__(self, section, name, default=None): self.section = section self.name = name self.default = default coreitems = {} def _register(configtable, *args, **kwargs): item = configitem(*args, **kwargs) 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)) section[item.name] = item # Registering actual config items def getitemregister(configtable): return functools.partial(_register, configtable) coreconfigitem = getitemregister(coreitems) coreconfigitem('devel', 'all-warnings', default=False, ) coreconfigitem('patch', 'fuzz', default=2, ) coreconfigitem('ui', 'clonebundleprefers', default=list, ) coreconfigitem('ui', 'interactive', default=None, ) coreconfigitem('ui', 'quiet', default=False, )