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
:%s/\/path\/to\/repo\/or\/config/\/repositories\/hgweb.config
:wq

4. Configure hgweb.config

vim /repositories/hgweb.config

[collections]
/repositories = /repositories

:wq

5. Configure Apache

vim /etc/apache2/sites-available/code.domain.com

ServerName code.domain.com
ServerAlias code.domain.com

ScriptAlias /repositories "/repositories/hgweb.cgi"

DocumentRoot /repositories

ErrorLog /var/log/apache2/code.domain.com-error_log
CustomLog /var/log/apache2/code.domain.com-access.log combined
LogLevel warn
ServerSignature Off

:wq

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
:wq

9. Configure email notifications for earlier created repository

vim /repositories/test/.hg/hgrc

[paths]
default = ssh://root@code.domain.com//repositories/configs
default-push = ssh://root@code.domain.com//repositories/configs
# in case you have ssh on a non standard port then you should use something like that
#default-push = ssh://root@code.domain.com:port//repositories/configs

[extensions]
hgext.notify=

[hooks]
changegroup.notify = python:hgext.notify.hook

[email]
from = mercurial@domain.com

[smtp]
host = domain.com

[web]
baseurl= http://code.domain.com/repositories/

[notify]
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]
user@example.com = *

[reposubs]
configs = user@example.com

:wq

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 *