configitems.py
215 lines
| 5.1 KiB
| text/x-python
|
PythonLexer
/ mercurial / configitems.py
r32983 | # 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 | ||||
r33126 | import functools | |||
r32984 | from . import ( | |||
error, | ||||
) | ||||
r33127 | def loadconfigtable(ui, extname, configtable): | |||
"""update config item known to the ui with the extension ones""" | ||||
for section, items in configtable.items(): | ||||
r33128 | 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) | ||||
r33127 | ||||
r32983 | 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, | ||||
David Demelier
|
r33329 | :alias: optional list of tuples as alternatives. | ||
r32983 | """ | |||
David Demelier
|
r33329 | def __init__(self, section, name, default=None, alias=()): | ||
r32983 | self.section = section | |||
self.name = name | ||||
self.default = default | ||||
David Demelier
|
r33329 | self.alias = list(alias) | ||
r32984 | ||||
coreitems = {} | ||||
r33126 | def _register(configtable, *args, **kwargs): | |||
r32984 | item = configitem(*args, **kwargs) | |||
r33126 | section = configtable.setdefault(item.section, {}) | |||
r32984 | 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 | ||||
r32986 | ||||
# Registering actual config items | ||||
r33126 | def getitemregister(configtable): | |||
return functools.partial(_register, configtable) | ||||
coreconfigitem = getitemregister(coreitems) | ||||
r33177 | coreconfigitem('auth', 'cookiefile', | |||
default=None, | ||||
) | ||||
r33178 | # bookmarks.pushing: internal hack for discovery | |||
coreconfigitem('bookmarks', 'pushing', | ||||
default=list, | ||||
) | ||||
r33179 | # bundle.mainreporoot: internal hack for bundlerepo | |||
coreconfigitem('bundle', 'mainreporoot', | ||||
default='', | ||||
) | ||||
r33180 | # bundle.reorder: experimental config | |||
coreconfigitem('bundle', 'reorder', | ||||
default='auto', | ||||
) | ||||
r33176 | coreconfigitem('color', 'mode', | |||
default='auto', | ||||
) | ||||
r33159 | coreconfigitem('devel', 'all-warnings', | |||
default=False, | ||||
) | ||||
r33160 | coreconfigitem('devel', 'bundle2.debug', | |||
default=False, | ||||
) | ||||
r33161 | coreconfigitem('devel', 'check-locks', | |||
default=False, | ||||
) | ||||
r33162 | coreconfigitem('devel', 'check-relroot', | |||
default=False, | ||||
) | ||||
r33163 | coreconfigitem('devel', 'disableloaddefaultcerts', | |||
default=False, | ||||
) | ||||
r33181 | coreconfigitem('devel', 'legacy.exchange', | |||
default=list, | ||||
) | ||||
r33164 | coreconfigitem('devel', 'servercafile', | |||
default='', | ||||
) | ||||
r33165 | coreconfigitem('devel', 'serverexactprotocol', | |||
default='', | ||||
) | ||||
r33166 | coreconfigitem('devel', 'serverrequirecert', | |||
r33174 | default=False, | |||
r33166 | ) | |||
r33167 | coreconfigitem('devel', 'strip-obsmarkers', | |||
default=True, | ||||
) | ||||
r33232 | coreconfigitem('format', 'aggressivemergedeltas', | |||
default=False, | ||||
) | ||||
r33233 | coreconfigitem('format', 'chunkcachesize', | |||
default=None, | ||||
) | ||||
r33234 | coreconfigitem('format', 'dotencode', | |||
default=True, | ||||
) | ||||
r33235 | coreconfigitem('format', 'generaldelta', | |||
default=False, | ||||
) | ||||
r33236 | coreconfigitem('format', 'manifestcachesize', | |||
default=None, | ||||
) | ||||
r33237 | coreconfigitem('format', 'maxchainlen', | |||
default=None, | ||||
) | ||||
r33241 | coreconfigitem('format', 'obsstore-version', | |||
default=None, | ||||
) | ||||
r33242 | coreconfigitem('format', 'usefncache', | |||
default=True, | ||||
) | ||||
r33243 | coreconfigitem('format', 'usegeneraldelta', | |||
default=True, | ||||
) | ||||
r33244 | coreconfigitem('format', 'usestore', | |||
default=True, | ||||
) | ||||
r33214 | coreconfigitem('hostsecurity', 'ciphers', | |||
default=None, | ||||
) | ||||
r33215 | coreconfigitem('hostsecurity', 'disabletls10warning', | |||
default=False, | ||||
) | ||||
r33226 | coreconfigitem('patch', 'eol', | |||
default='strict', | ||||
) | ||||
r32988 | coreconfigitem('patch', 'fuzz', | |||
default=2, | ||||
) | ||||
r33245 | coreconfigitem('progress', 'assume-tty', | |||
default=False, | ||||
) | ||||
r33246 | coreconfigitem('progress', 'clear-complete', | |||
default=True, | ||||
) | ||||
r33247 | coreconfigitem('progress', 'estimate', | |||
default=2, | ||||
) | ||||
r33216 | coreconfigitem('server', 'bundle1', | |||
default=True, | ||||
) | ||||
r33217 | coreconfigitem('server', 'bundle1gd', | |||
default=None, | ||||
) | ||||
r33218 | coreconfigitem('server', 'compressionengines', | |||
default=list, | ||||
) | ||||
r33219 | coreconfigitem('server', 'concurrent-push-mode', | |||
default='strict', | ||||
) | ||||
r33220 | coreconfigitem('server', 'disablefullbundle', | |||
default=False, | ||||
) | ||||
r33221 | coreconfigitem('server', 'maxhttpheaderlen', | |||
default=1024, | ||||
) | ||||
r33222 | coreconfigitem('server', 'preferuncompressed', | |||
default=False, | ||||
) | ||||
r33223 | coreconfigitem('server', 'uncompressedallowsecret', | |||
default=False, | ||||
) | ||||
r33224 | coreconfigitem('server', 'validate', | |||
default=False, | ||||
) | ||||
r33225 | coreconfigitem('server', 'zliblevel', | |||
default=-1, | ||||
) | ||||
r32989 | coreconfigitem('ui', 'clonebundleprefers', | |||
r33151 | default=list, | |||
r32989 | ) | |||
r33061 | coreconfigitem('ui', 'interactive', | |||
default=None, | ||||
) | ||||
r32986 | coreconfigitem('ui', 'quiet', | |||
default=False, | ||||
) | ||||
David Demelier
|
r33329 | coreconfigitem('ui', 'username', | ||
alias=[('ui', 'user')] | ||||
) | ||||
r33231 | # Windows defaults to a limit of 512 open files. A buffer of 128 | |||
# should give us enough headway. | ||||
r33227 | coreconfigitem('worker', 'backgroundclosemaxqueue', | |||
default=384, | ||||
) | ||||
r33228 | coreconfigitem('worker', 'backgroundcloseminfilecount', | |||
default=2048, | ||||
) | ||||
r33229 | coreconfigitem('worker', 'backgroundclosethreadcount', | |||
default=4, | ||||
) | ||||
r33230 | coreconfigitem('worker', 'numcpus', | |||
default=None, | ||||
) | ||||