Mercurial > hg
view mercurial/configitems.py @ 33039:b82615afde65
bundle: add a applybundle1() method
This is one step towards removing a bunch of "if isinstance(gen,
unbundle20)" by treating bundle1 and bundle2 more similarly.
The name may sounds ironic for a method in the bundle2 module, but I
didn't think it was worth it yet to create a new 'bundle' module that
depends on the 'bundle2' module. Besides, we'll inline the method
again later.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jun 2017 10:25:11 -0700 |
parents | 03608e8d09e9 |
children | c41cbe98822c |
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 from . import ( error, ) 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 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 # Registering actual config items coreconfigitem('patch', 'fuzz', default=2, ) coreconfigitem('ui', 'clonebundleprefers', default=[], ) coreconfigitem('ui', 'quiet', default=False, )