Proper way to register configs in hooks

Yuya Nishihara yuya at tcha.org
Sun Dec 3 07:04:06 UTC 2017


On Thu, 30 Nov 2017 11:00:30 -0500, Olivier Trempe wrote:
> 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?

Perhaps the hook script can be loaded as an extension? I don't think we'll
extend the config registrar machinery to hooks since in-process hooks are
discouraged.


More information about the Mercurial-devel mailing list