Proper way to register configs in hooks

Olivier Trempe oliviertrempe at gmail.com
Thu Nov 30 16:00:30 UTC 2017


Hi,

First, I understand that the new configitems.loadconfigtable is called for
each activated extension and expects to find a configtable object within
the extension module to inject the extension's configs into the ui's known
configs. I had to step into the code to find out about it and it is not
documented in https://www.mercurial-scm.org/wiki/WritingExtensions

What would be the proper way to register a config used in a hook?

There is no call to configitems.loadconfigtable when a hook module is
loaded. If I manually register a config on the ui object passed to the
hook, this config will be registered as many times as the hook is called. I
could check if the config has already been registered before registering
it, but this is more a workaround than a clean solution.

Is this something that is not properly handled yet? Should
configitems.loadconfigtable be called right after obj = __import__(modname) in
hook.py?

Thanks

Olivier Trempe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20171130/02dafcc3/attachment-0001.html>


More information about the Mercurial-devel mailing list