I\'m searching for info to setup a Mercurial Server for Windows (7 or XP) with an Apache (xampp if it is useful to know it) with the Push Model, just like in this question but m
I used the HgWebDir instructions:
Here is my httpd.conf piece for the mercurial sites (slightly edited):
<VirtualHost *:88>
ServerName hg.example.com
DocumentRoot c:/apache_sites/hg
RewriteEngine on
RewriteRule ^/$ /public [R]
RewriteRule ^/public(.*) /public/hgwebdir.cgi$1 [L]
RewriteRule ^/private(.*) /private/hgwebdir.cgi$1 [L]
# mod_alias alternative (pretty url's)
<Directory c:/apache_sites/hg >
Order allow,deny
Allow from all
AllowOverride All
Options ExecCGI
AddHandler cgi-script .cgi
</Directory>
<Location /private/>
AuthType Digest
AuthName "hg.example.com"
AuthDigestProvider file
AuthUserFile c:/apache_sites/hg/hgusers
AuthGroupFile c:/apache_sites/hg/hggroup
AuthDigestDomain /private/
Require group owner
</Location>
<Location /public/>
AuthType Digest
AuthName "hg.example.com"
AuthDigestProvider file
AuthUserFile c:/apache_sites/hg/hgusers
AuthGroupFile c:/apache_sites/hg/hggroup
AuthDigestDomain /public/
<LimitExcept GET>
Require group developer
</LimitExcept>
</Location>
LogLevel debug
ErrorLog "c:/apache/logs/hg-error.log"
CustomLog "c:/apache/logs/hg-access.log" combined
LogLevel debug
</VirtualHost>
# vim:se ft=apache:
I also had to turn on a few modules for Auth Digest, etc.
I put the hgwebdir.cgi in the root of the public and the private folders, and just put each of my hg repos in the repos subfolder under the appropriate folders.
Apache authentication took care of my authorization.
Then I just put a hgweb.config file in the same locations like this:
[collections]
repos = repos
[web]
allow_archive = bz2 gz zip
style = gitweb
baseurl = /public
Updated Question
The mercurial packages need to be on the PYTHON_PATH
This answer gives more detail.
John Weldons answer is correct, I just wanted to provide a little detail on the wide array of possibilities you may also be interested in.
hgwebdir is just a wsgi application, so you can run it like any other wsgi application using mod_wsgi in apache2. mod_wsgi will also perform better than cgi because the overhead of loading the python interpreter is done once rather than for each request.
Also by virtue of being a wsgi application means you can also wrap it up in middleware, or hang it off another url of a bigger website etc...
For example, say you are using trac(another wsgi app) and you want to share the authorization scheme between trac and hgwebdir, this can be accomplished by putting them both behind authorization middleware like repoze.who for example.
Finally, since python paste makes building web apps out of smaller pieces, I wrote this code snippet to start hgwebdir via paste.
"""
Wsgi wrapper of hgweb that is paste compatible
"""
import os
from mercurial import demandimport
demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
CONFIG_FILE_KEY = "hgwebdir.config"
def hgweb_paste(global_config, **local_conf):
"""
looking for a config file setting in global or local
"""
cfg = global_config
cfg.update(local_conf)
config_file = cfg.get(CONFIG_FILE_KEY)
if config_file and os.path.exists(config_file):
return hgwebdir(config_file)
else:
raise KeyError, "%s not set or %s does not exist" % (CONFIG_FILE_KEY,config_file)
And the corresponding config file part to load it...
[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 6543
[app:main]
use = egg:hg.paste#hgweb
hgwebdir.config = %(here)s/hg.config
I found this blog post particularly helpful: http://blog.riverside-software.fr/2011/02/quick-and-easy-setup-of-mercurial.html.
It's simple, to the point, and got me up and working in less than 15 minutes.