Setup Mercurial over SSL with Apache

Since some of my SVN Repositories did not survive the last Update of the Database, and were really hard to recover, or some even needed to be recovered from older Backup, I decided to switch to Mercurial for all me Repository needs.

Looking around on the Web there a probably 100s of guides explaining the basics and setup, but actually None of them worked as a whole for me, so I decided to write down my experiences maybe they apply to somebody, and if not, at least it will be easier for me next time.

First of all thanks to the following Guides I got everything working:

Second I’m running on a Debian Lenny Server with all Updates until 5/5/2009, Mercurial is 1.0.1, Apache is Apache/2.2.9 (Debian).

Now a couple hints, make sure cgi is enabled

sudo a2enmod cgi
sudo a2enmod cgid

Now Setup a new Location for Mercurial like this one

ScriptAliasMatch ^/merc(.*) /MYREPOPATH/hgwebdir.cgi$1
   <Location /merc>
   Allow from all
   Options ExecCGI
   AuthType Digest
   AuthName “REPOSNAME”
   AuthDigestProvider file
   AuthUserFile PATHTOPASSWORDFILE
   Require valid-user
   </Location>

Now copy the file hgwebdir.cgi found in /usr/share/hg to the Repository Path and Setup a hgweb.config file in the same location to point to your repositories

[collections]
MYREPOPATH = MYREPOPATH

Now just the repositories need to be initilized in this Path

mkdir testrepo
cd testrepo && hg init

and the Password file has to be created

mkdir testrepo
htdigest -c PASSWORDFILE ‘REPOSNAME’ USERNAME

If you now add allow_push = USERNAME to the hgrc file for the repository you can push your changes to the newly initilized repository after cloning it.

Hope those hints will help, if not comments are welcome.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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