Search code examples
mercurialmercurial-hook

How to read hgrc properties from Mercurial hook


I did not find anything from the Mercurial hook documentation explaining how to get properties of the repository's hgrc file from a custom python hook.

As the documentation states that we have access to the full Mercurial API from hooks, I suppose this should be possible. But how?

Moreover I could not find a precise documentation on what are the objects (ui, repos, ...) passed in argument to the Mercurial hook.


Solution

  • Ok I find out the answer by myself.

    This page gives some hints about the argument passed to the hook functions: https://www.mercurial-scm.org/wiki/MercurialApi#Reading_configuration_files

    ui.config functions permit to read Mercurial configuration files, giving the section and property name.