pythonmercurialhookmercurial-hook

How to access commit message from Mercurial Input or Changeset hook


I would like to write a hook for Mercurial to do the following, an am struggling to get going.:

So, just for starters, how can I get the commit message for each commit from the "input" or "changegroup" hook? Any advice beyond this on how to achieve the other points would also be appeciated.

Thanks for any help.


Solution

  • You will want to use the incoming hook which is called for each changeset that is applied on the repository (either via pull, push or unbundle).

    In the calling script, the current changeset id will be accessible through the HG_NODE environment variable, in python you can access it with os.environ['HG_NODE'].

    Depending on how you want to do it, have a look at the provided bugzilla hook as a starting point.