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 = [email protected]
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.config
and the related methods to read the config values:
address = ui.config('changegroup.mail_someone', 'to_address')
You can also use ui.configbool
and ui.configlist
to read Booleans and lists, respectively.
An external hook can use hg showconfig
to extract the configuration value:
$ hg showconfig changegroup.mail_someone.to_address
That will return [email protected]
on stdout. You can use
$ hg showconfig changegroup.mail_someone
to see all settings in that particular section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With