Search code examples
mercurialmercurial-hookmercurial-queue

How to add hooks for Mercurial MQ commands?


I would like to setup hg hooks for some actions done by mq extension. For example when I do

hg qnew

I would like to use post-review to create a new review request in our reviewboard server. I would also like to make a hook that updates the diff if you do

hg qrefresh

Is this possible?


Solution

  • All Mercurial commands have both a pre-XXX and post-XXX hook. So you can write write hooks like:

    [hooks]
    post-qnew.reviewboard = post-review $(hg root)/.hg/patches/$(hg qtip)
    post-qrefresh.reviewboard = post-review $(hg root)/.hg/patches/$(hg qtip)
    

    or whatever the correct post-review invocation is.

    All examples approximate. :)