I know how to specify which hooks are run when. What I want to know is if it is possible to pass config into the hook via the hgrc file. Extensions can do this, e.g.
[extensions]
someextension = something
[someextension]
some.config = 1
some.other.config = True
I want to be able to do something similar for hooks, e.g.
[hooks]
changegroup.mail_someone = python:something
[changegroup.mail_someone]
to_address = some.email.address@somewhere.com
Is something like this possible? Searching for a way to do this hasn’t turned up anything useful… If it is possible, how do I go about reading in the config in my (Python in-process) hook handler?
Let me answer for both hook types:
An in-process hook would use
ui.configand the related methods to read the config values:You can also use
ui.configboolandui.configlistto read Booleans and lists, respectively.An external hook can use
hg showconfigto extract the configuration value:That will return
some.email.address@somewhere.comon stdout. You can useto see all settings in that particular section.