[PATCH 2 of 6] configitems: add an official API for extensions to register config item
Yuya Nishihara
yuya at tcha.org
Thu Jun 29 09:48:08 EDT 2017
On Tue, 27 Jun 2017 15:00:31 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at octobus.net>
> # Date 1497700100 -7200
> # Sat Jun 17 13:48:20 2017 +0200
> # Node ID 944f8e3191e6fa37f27d52d3c94d1ef702408ae4
> # Parent 714ce79885e32305c45febf0da59b2ce2093967d
> # EXP-Topic config.register
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 944f8e3191e6
> configitems: add an official API for extensions to register config item
>
> Extensions can have a 'configtable' mapping and use
> 'registrar.configitem(table)' to retrieve the registration function.
>
> This behave in the same way as the other way for extensions to register new
> items (commands, colors, etc).
>
> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
> --- a/mercurial/configitems.py
> +++ b/mercurial/configitems.py
> @@ -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)
So this effectively updates the global configitems.coreitems, and that's
unavoidable since the passed ui is a temporary object.
Do you have a plan to make _knownconfig a real local variable?
More information about the Mercurial-devel
mailing list