##// END OF EJS Templates
configitems: add an official API for extensions to register config item...
marmoute -
r33127:c467d133 default
parent child Browse files
Show More
@@ -13,6 +13,11 b' from . import ('
13 error,
13 error,
14 )
14 )
15
15
16 def loadconfigtable(ui, extname, configtable):
17 """update config item known to the ui with the extension ones"""
18 for section, items in configtable.items():
19 ui._knownconfig.setdefault(section, {}).update(items)
20
16 class configitem(object):
21 class configitem(object):
17 """represent a known config item
22 """represent a known config item
18
23
@@ -18,6 +18,7 b' from .i18n import ('
18
18
19 from . import (
19 from . import (
20 cmdutil,
20 cmdutil,
21 configitems,
21 encoding,
22 encoding,
22 error,
23 error,
23 pycompat,
24 pycompat,
@@ -263,6 +264,7 b' def loadall(ui, whitelist=None):'
263 extraloaders = [
264 extraloaders = [
264 ('cmdtable', commands, 'loadcmdtable'),
265 ('cmdtable', commands, 'loadcmdtable'),
265 ('colortable', color, 'loadcolortable'),
266 ('colortable', color, 'loadcolortable'),
267 ('configtable', configitems, 'loadconfigtable'),
266 ('filesetpredicate', fileset, 'loadpredicate'),
268 ('filesetpredicate', fileset, 'loadpredicate'),
267 ('revsetpredicate', revset, 'loadpredicate'),
269 ('revsetpredicate', revset, 'loadpredicate'),
268 ('templatefilter', templatefilters, 'loadfilter'),
270 ('templatefilter', templatefilters, 'loadfilter'),
@@ -8,11 +8,19 b''
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from . import (
10 from . import (
11 configitems,
11 error,
12 error,
12 pycompat,
13 pycompat,
13 util,
14 util,
14 )
15 )
15
16
17 # unlike the other registered items, config options are neither functions or
18 # classes. Registering the option is just small function call.
19 #
20 # We still add the official API to the registrar module for consistency with
21 # the other items extensions want might to register.
22 configitem = configitems.getitemregister
23
16 class _funcregistrarbase(object):
24 class _funcregistrarbase(object):
17 """Base of decorator to register a function for specific purpose
25 """Base of decorator to register a function for specific purpose
18
26
@@ -5,6 +5,9 b' Test basic extension support'
5 > from mercurial import commands, registrar
5 > from mercurial import commands, registrar
6 > cmdtable = {}
6 > cmdtable = {}
7 > command = registrar.command(cmdtable)
7 > command = registrar.command(cmdtable)
8 > configtable = {}
9 > configitem = registrar.configitem(configtable)
10 > configitem('tests', 'foo', default="Foo")
8 > def uisetup(ui):
11 > def uisetup(ui):
9 > ui.write("uisetup called\\n")
12 > ui.write("uisetup called\\n")
10 > ui.flush()
13 > ui.flush()
@@ -14,7 +17,9 b' Test basic extension support'
14 > ui.flush()
17 > ui.flush()
15 > @command(b'foo', [], 'hg foo')
18 > @command(b'foo', [], 'hg foo')
16 > def foo(ui, *args, **kwargs):
19 > def foo(ui, *args, **kwargs):
17 > ui.write("Foo\\n")
20 > foo = ui.config('tests', 'foo')
21 > ui.write(foo)
22 > ui.write("\\n")
18 > @command(b'bar', [], 'hg bar', norepo=True)
23 > @command(b'bar', [], 'hg bar', norepo=True)
19 > def bar(ui, *args, **kwargs):
24 > def bar(ui, *args, **kwargs):
20 > ui.write("Bar\\n")
25 > ui.write("Bar\\n")
General Comments 0
You need to be logged in to leave comments. Login now