Search code examples
mercurialhgrcmercurial-hook

How do I set up a hook in HG / Mercurial that gets dictated by the repository?


I have a need for a hook to run after update (this will build the solution they have updated) and I don't want to have to add that hook manually for each person that clones my central repository.

When someone first clones my central repository, is it possible to include hooks into that clone? It seems that the .hgrc file doesn't get cloned automatically.

I did read about site-wide hooks, but as far as I understand it, they work on each created repository, where I only want to have the hooks on some repos.


Solution

  • As Rudi already said, this is (thankfully) not possible for security reasons.

    However, you can reduce the per-clone workload to set up hooks manually: Ship the hook scripts as part of your repository, e.g. in a directory .hghooks, and additionally include a script in your repo which sets up these hooks in a clone's hgrc. Each coworker now only needs to call the setup script once per clone.