@@ -13,6 +13,11 @@ 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():
+ ui._knownconfig.setdefault(section, {}).update(items)
+
class configitem(object):
"""represent a known config item
@@ -25,6 +25,7 @@ from . import (
cmdutil,
color,
commands,
+ configitems,
demandimport,
encoding,
error,
@@ -736,6 +737,7 @@ def _checkshellalias(lui, ui, args):
extraloaders = [
('cmdtable', commands, 'loadcmdtable'),
('colortable', color, 'loadcolortable'),
+ ('configtable', configitems, 'loadconfigtable'),
('filesetpredicate', fileset, 'loadpredicate'),
('revsetpredicate', revset, 'loadpredicate'),
('templatefilter', templatefilters, 'loadfilter'),
@@ -8,11 +8,19 @@
from __future__ import absolute_import
from . import (
+ configitems,
error,
pycompat,
util,
)
+# unlike the other registered items, config options are neither functions or
+# classes. Registering the option is just small function call.
+#
+# We still add the official API to the registrar module for consistency with
+# the other items extensions want might to register.
+configitem = configitems.getitemregister
+
class _funcregistrarbase(object):
"""Base of decorator to register a function for specific purpose
@@ -5,6 +5,9 @@ Test basic extension support
> from mercurial import commands, registrar
> cmdtable = {}
> command = registrar.command(cmdtable)
+ > configtable = {}
+ > configitem = registrar.configitem(configtable)
+ > configitem('tests', 'foo', default="Foo")
> def uisetup(ui):
> ui.write("uisetup called\\n")
> ui.flush()
@@ -14,7 +17,9 @@ Test basic extension support
> ui.flush()
> @command('foo', [], 'hg foo')
> def foo(ui, *args, **kwargs):
- > ui.write("Foo\\n")
+ > foo = ui.config('tests', 'foo')
+ > ui.write(foo)
+ > ui.write("\\n")
> @command('bar', [], 'hg bar', norepo=True)
> def bar(ui, *args, **kwargs):
> ui.write("Bar\\n")