2011年1月28日星期五

Publishing hg Repositories with hgwebdir.cgi

This is how to set up a web hg repos server:


# mkdir /var/hg
# cd /var/hg
# mkdir repos
# cd repos
# sudo -u www-data hg init project_name

hgwebdir.cgi

#!/usr/bin/env python
#

from mercurial import demandimport; demandimport.enable()

import cgitb
cgitb.enable()

from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi

application = hgwebdir('/var/hg/hgweb.config')
wsgicgi.launch(application)


hgweb.config

[collections]
repos/ = repos/

[web]
style = gitweb
baseurl = /hg



=========== set apache2 ========

# cd /etc/apache2/sites-enabled

hg.conf

ScriptAliasMatch ^/hg(.*) /var/hg/hgwebdir.cgi$1

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

<Location /hg>
DAV on
AuthType Basic
AuthName "hg"
AuthUserFile /etc/apache2/dav.passwd
Require valid-user
</Location>


# htpasswd -c /etc/appache2/dav.passwd user

# /etc/init.d/apache2 restart

# sudo chown -Rh www-data:www-data /var/hg

# sudo chmond +x /var/hg/hgwebdir.cgi

1 条评论:

  1. .hg/hgrc

    ---
    [ui]
    username = guan

    [web]
    contact = guan
    description = guan san
    allow_push = *
    push_ssl = false

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

    [notify]
    maxdiff = 300

    回复删除