How to install mercurial on debian squeeze

This document describes how to install and configure mercurial on linux debian squeeze. With minor changes you can use this procedure on different linux distributions.

1. Install required packages

aptitude install mercurial libapache2-mod-wsgi

2. Create repositories directories

mkdir -pv /repositories
chown -R www-data:www-data /repositories
cd /repositories

3. Configure hgweb.cgi script in order to server the repositories via Apache

cp /usr/share/doc/mercurial/examples/hgweb.cgi .
chmod a+x hgweb.cgi
vim /repositories/hgweb.cgi

4. Configure hgweb.config

vim /repositories/hgweb.config

/repositories = /repositories


5. Configure Apache

vim /etc/apache2/sites-available/


ScriptAlias /repositories "/repositories/hgweb.cgi"

DocumentRoot /repositories

ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ combined
LogLevel warn
ServerSignature Off


6. Restart Apache

/etc/init.d/apache2 restart

7. Make a test repository

mkdir test
cd test
hg init

8. Enable notify extension

vim /etc/mercurial/hgrc.d/hgext.rc
:%s/# hgext.notify/hgext.notify

9. Configure email notifications for earlier created repository

vim /repositories/test/.hg/hgrc

default = ssh://
default-push = ssh://
# in case you have ssh on a non standard port then you should use something like that
#default-push = ssh://


changegroup.notify = python:hgext.notify.hook

from =

host =


sources = serve

test = False
diffstat = False
merge = False

maxdiff = 0

template = Subject: [{webroot|basename}]: {desc|strip|firstline}\n\ndetails: {baseurl}{webroot|basename}/rev/{node|short}\nchangeset: {rev}:{node|short}\nuser: {author}\ndate: {date|date}\ndescription:\n{desc}\n\nfiles changed:\n {files}\n\n\n

[usersubs] = *

configs =


10. Copying some files in the repository

rsync -avz /some/files/* .
hg add
hg status
hg commit -m "Added initial files to the repo" -u user
hg push

One thought on “How to install mercurial on debian squeeze”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.