This is a tiny Python project as a hook to notify developers of a project when one of them pushes/commits the source. The target of this project was making our team get habit to push and pull more periodically and reduce the merge conflicts. After Googling, I noticed there is just an Email notification extension and nothing for jabber. In some forum, a developer made a hook as out-of-process command line shell using "xsend.py" file from XMPPY sample files with some modification. Since Mercurial is written in Python, I got the idea and made a little Python project doing the same, with a bit extra features.
How to use?
Normally, you can add hooks to Mercurial using configuration file as so:
[hooks] changegroup = python:hgxmpp.hook
There are some predefined hook keywords: changegroup (for push), commit (for commit) and some more you can get a complete list http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html
Now, you must install xmpppy as prerequisites for his packages.
pip install xmpppy
Then just extract the package files into your Python package library (or some folder in PYTHON_PATH variable). You can test this process by using the following command in your Python interpreter:
If you get errors, revise the process. The module must be publicly available.
We have some configuration options here. Evidently, you have to provide you jabber id and password for sending notifications from. After that, you must specify the group of jabber users should get the notification for each project:
[hooks] changegroup = python:hgxmpp.hook [jabber] userid = email@example.com password = mercurialpassword MyProject = firstname.lastname@example.org, email@example.com
Thats it! Currently there is no more configuration needed here. The format of message is as the following:
Pushed node 67eb80fc7e11 from remote:http::K.Inanloo
As you can see, the first line is the event name, the second is the node hash, and the last is the user who has pushed and the type of doing the action.
TODO: Make the format of message changeable using some configuration options.