At work we use trac for feature planning and defect management. Having recently moved from Subversion to Mercurial (Hg) we needed to install hooks in our Hg repositories so that trac tickets could be modified and closed via special commit messages commands.
Hooks are added to a repository’s configuration file (
.hg/hgrc) as follows
[hooks] incoming = /usr/bin/trac-admin /trac/project/directory added Reponame $HG_NODE
This repository is then served using hgwebdir running via Apache mod_wsgi.
hgwebdir.config configures the repositories that are shown, their filesystem locations, permissions, etc.
For the life of me I couldn’t figure out why the trac incoming hook wasn’t running. After a lot of tail chasing and advice from #mercurial we discovered the solution.
It turns out that by default Hg will ignore
.hg/hgrc files that aren’t owned by a trusted user. Since our repositories are 2775/664 root:apache and the server process only trusts
.hg/hgrc files that it owns, all our repository specific config options are ignored.
[trusted] users = root
hgweb.config fixed the problem and our trac hooks now run as desired.