Remote hooks with mercurial

If you use mercurial in a centralized model – it can be a little fiesty to create and troubleshoot your hooks.

You’ll want to make sure you scan over the /hgrc hooks section and the redbook section on hooks

First, a few rule of thumbs:

  1. It’s possible to write them in bash/sh, and python
  2. If bash-style, your script is executed with your user’s shell. No need to put #!/bin/bash on top really (helps in vim though)
  3. Your script must be +x for the user that’s executing it. (Remote push over http/s, your www/apache user must have +x to it)

How to troubleshoot is easy, I start like this, from /home/rovangju:

This will set the stage. Then we’ll create our hook:

Your hook is now good to go!
Now, in order to fire this off we need to emulate a centralized model, so when we push to the main, we’ll fire off our hook.


If your file looks like that with the correct path try:

If all goes well you’ll see something like:

And that’s your starting point for your hook.
I just wanted to throw this out there for myself and others someday if they’re trying to find a better way to troubleshoot why their hook isn’t firing or working.
Also, logger is your friend!

No Comments

Start the ball rolling by posting a comment on this article!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">