ponedeljek, 14. februar 2011

Mercurial server installation for Windows

Installation of hgweb interface:
- install Apache HTTPD 2.2 to c:/Apps/Apache
- install Python 2.6 to c:/Python26
- install Mercurial to C:/Apps/HG
- install EasyInstall
This will find your Python installation and install it there.
- put c:/Python26 and c:/Python26/Scripts in you PATH
- install Flup Python module
easy_install flup-1.0.3.dev_20110111-py2.6.egg
- unzip C:/Apps/HG/library.zip C:/Apps/HG/dev
- copy c:/Apps/HG/templates directory to c:/Apps/HG/dev/templates

I have my Mercurial repositories in d:/HG/repos.

hgweb.fcgi in d:/HG looks like:

#!C:/Python26/python.exe -u
# An example FastCGI script for use with flup, edit as necessary

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "d:/HG/hgweb.config"

# Uncomment and adjust if Mercurial is not installed system-wide:
import sys
sys.path.insert(0, "C:/Apps/HG/dev")

# Uncomment to send python tracebacks to the browser if an error occurs:
import cgitb; cgitb.enable()

import os
os.environ["HGENCODING"] = "UTF-8"

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
from flup.server.fcgi import WSGIServer
application = hgweb(config)

- configuration file for hgweb (d:/HG/hgweb.config) looks like:

# One repository
#FOO = d:/HG/repos/FOO
# All repositories in d:/HG/repos
/ = d:/HG/repos/**

style = gitweb

- each repository under d:/HG/ has hgrc (in UTF-8) like this:

description = Repository description
style = gitweb
allow_push = *
push_ssl = false
verbose = false
allowbz2 = yes
allowgz = yes
allowzip = yes

username = Owner of repo <repo.owner@example.com>
debug = false

NOTE: debug and verbose have to be false

- edit c:/Apps/Apache/conf/httpd.conf and add:

LoadModule cgi_module modules/mod_cgi.so
LoadModule env_module modules/mod_env.so

ScriptAliasMatch ^/hg(.*) d:/HG/hgweb.fcgi$1
<Directory d:/HG>
Options ExecCGI FollowSymLinks
AllowOverride None
AddHandler cgi-script .cgi
Allow from all
AllowOverride All

- if you want to limit access to repositories add this to c:/Apps/Apache/conf/httpd.conf

<Location /hg>
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile D:/HG/hgusers
Require valid-user

- then add valid users to D:/HG/hgusers like this:

htpasswd -c D:/HG/hgusers frodo # creates file D:/HG/hgusers and adds user frodo
htpasswd D:/HG/hgusers sam # only add usersam to exising D:/HG/hgusers file
Objavite komentar