Recently I have discovered the awesome mercurial-server. It gives flexible access control, takes care of file permission (which was problematic in our previous setup) and allows to hide physical path of the repo from its URL. It also offers global configuration file, which can include hooks for all of the repositories.
This offers an advantage in setting mail notifications using NotifyExtension. In our previous setup we had included all the options and the template in each’s repository hgrc file. It required us to use some setup script for creating repositories and was somewhat clumsy - there were no feel of some global administration.
Using global configuration allow us to easily put the configuration in the global rc file (in
/etc/mercurial-server/remote-hgrc.d/ dir) pointing to the template inside
hgadmin repo. There would still be need to put
reposubs sections in each repository’ hgrc to specify who gets notification from which repo but it is now much cleaner and only info about specific repo goes to the hgrc.
Global subscribers configuration
We wanted to get one step further and have some global configuration of subscribers in one place (and preferably in
hgadmin repo), but this required some extra effort. Since I have not found a way to use any variables in
reposubs section (which specifies who gets notified) we decided that all emails will go to local account (
hg@localhost at the server), and will include custom header (X-Repo) with the repository name (it was easily added in the style file).
Then we use procmail to handle routing:
If email have the
X-Repo header we search for subscribers in the repository’s file (addresses can be separated by spaces or newlines). If there is no relevant file, a warning email is sent to the default address, so we do not forget about any created repo.
Then procmail forwards the notification email to the subscribers and we are happy. Of course one could have even more advanced setup involving reading groups or privileges from LDAP, etc.
But maybe you know a simpler way (without procmail) to achieve this?
Below you see our configuration files: