##// END OF EJS Templates
dirstate: expose a sparse matcher on dirstate (API)...
dirstate: expose a sparse matcher on dirstate (API) The sparse extension performs a lot of monkeypatching of dirstate to make it sparse aware. Essentially, various operations need to take the active sparse config into account. They do this by obtaining a matcher representing the sparse config and filtering paths through it. The monkeypatching is done by stuffing a reference to a repo on dirstate and calling sparse.matcher() (which takes a repo instance) during each function call. The reason this function takes a repo instance is because resolving the sparse config may require resolving file contents from filelogs, and that requires a repo. (If the current sparse config references "profile" files, the contents of those files from the dirstate's parent revisions is resolved.) I seem to recall people having strong opinions that the dirstate object not have a reference to a repo. So copying what the sparse extension does probably won't fly in core. Plus, the dirstate modifications shouldn't require a full repo: they only need a matcher. So there's no good reason to stuff a reference to the repo in dirstate. This commit exposes a sparse matcher to dirstate via a property that when looked up will call a function that eventually calls sparse.matcher(). The repo instance is bound in a closure, so it isn't exposed to dirstate. This approach is functionally similar to what the sparse extension does today, except it hides the repo instance from dirstate. The approach is not optimal because we have to call a proxy function and sparse.matcher() on every property lookup. There is room to cache the matcher instance in dirstate. After all, the matcher only changes if the dirstate's parents change or if the sparse config changes. It feels like we should be able to detect both events and update the matcher when this occurs. But for now we preserve the existing semantics so we can move the dirstate sparseness bits into core. Once in core, refactoring becomes a bit easier since it will be clearer how all these components interact. The sparse extension has been updated to use the new property. Because all references to the repo on dirstate have been removed, the code for setting it has been removed.

File last commit:

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