aAPT
dDebian
fFFmpeg
jJava
mMercurial: Usage
oOCaml
pPostgreSQL

Home Applications Hg

Mercurial: hgweb

Setting hgweb permissions

chown -R FOO:www-data REPOS
chmod -R g+rw REPOS
chmod g+x REPOS
chmod g+x REPOS/*
chmod g+x REPOS/*/.hg

Adding new repository

cd /srv/hg
hg init REPO
chown -R root.www-data REPO
chmod g+w REPO/.hg
chmod g+w REPO/.hg/store
hginit script
#!/bin/sh

set -e

usage() {
    echo "Usage: $(basename $0) REPOSITORY"
    exit $1
}

if [ "$(id -u)" -ne 0 ]; then
    echo "This command should be run as root"
    exit 1
fi

if [ "$#" -ne 1 ]; then
    usage 1
fi

if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
    usage 0
fi

GROUP=www-data
REPO="$1"
HGRC="$REPO"/.hg/hgrc

hg init "$REPO"
chown -R root.$GROUP "$REPO"
chmod g+w "$REPO/.hg"
chmod g+w "$REPO/.hg/store"

cat << EOF > "$HGRC"
[web]
description   = Repository description
encoding      = UTF-8
allow_archive = gz, bz2
allow_push    = uname
EOF

chmod 640 "$HGRC"
chown root.$GROUP "$HGRC"
echo "Don't forget to add the description and users to $HGRC"

Apache HTTP configuration

Add user:

htpasswd [-c] /etc/apache2/passwd-hg USER_NAME
site.conf
<VirtualHost *:443>
        ...
        ServerName hg.example.org

	DocumentRoot /var/www/hg

	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>

	<Directory /var/www/hg>
		Options FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

	WSGIScriptAlias / /var/www/hg/hgweb.wsgi

	<Location />
		AuthType Basic
		AuthName "Mercurial repositories"
		AuthUserFile /etc/apache2/passwd-hg
		Require valid-user
        </Location>
        ...
</VirtualHost>
hgweb.config
[paths]
/ = /srv/hg/*

[web]
style = gitweb
encoding = "UTF-8"
hgweb.wsgi
# An example WSGI for use with mod_wsgi, edit as necessary
# See http://mercurial.selenic.com/wiki/modwsgi for more information

config = "/srv/hg/hgweb.config"
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
# python2
# application = hgweb(config)
application = hgweb(config.encode('utf-8'))

hgrc
[web]
description   = My repository
encoding      = UTF-8
allow_archive = gz, bz2
allow_push    = uname

Resources

Publishing mercurial repositories