- Install mercurial
after installing mercurial, type "python" and type "import mercurial" on terminal.
user$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mercurial
>>>
if error, refer to http://mercurial.selenic.com/wiki/PublishingRepositories
(cf 3.1.1 Python and Mercurial )
- Make hgweb script
make hgweb.cgi file in the path "/Volumes/works/hg".
and then add the following contents on it.
( in this guide, we assume that mercurial works are in the path "/Volumes/works/hg". so all config files might be there.)
#!/usr/bin/env python
#
# send python tracebacks to the browser if an error occurs:
import cgitb
cgitb.enable()
# An example CGI script to export multiple hgweb repos, edit as necessary
# adjust python path if not a system-wide install:
import sys
but, if you want to have multiple repositories, do it like this
/ = /Volumes/works/hg/*
so you can access all repositories under /Volumes/works/hg/
ex)
https://example.com/hg/project1
https://example.com/hg/project2
.... and so on.
allow_push = johnson
this would allow pushing for johnson.
you can allow pushing for everyone as like this
allow_push = *
To make user id and password for mercurial, use htpasswd command.
htpasswd -c /Volumes/works/hg/hgusers johnson
(cf htpasswd )
and we have to change permission of repositories.
chown -R _www:_www /Volumes/works/hg
chmod -R g+rw /Volumes/works/hg
chmod -R g+x /Volumes/works/hg
chmod -R g+x /Volumes/works/hg/*
chmod -R g+x /Volumes/works/hg/*/.hg
_www is a group for apache web service.
make httpd-hg.conf file in the path /Volumes/works/hg. and add the following text on it.
# Mercurial setting
ScriptAlias /hg "/volumes/works/hg/hgweb.cgi"
#restrict pushing to known users
<Location /hg>
#Require SSL authentication
SSLRequireSSL
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /volumes/works/hg/hgusers
Require valid-user
</Location>
add the following text on /etc/apache2/httpd.conf.
( in this guide, we assume that mercurial works are in the path "/Volumes/works/hg". so all config files might be there.)
#!/usr/bin/env python
#
# send python tracebacks to the browser if an error occurs:
import cgitb
cgitb.enable()
# An example CGI script to export multiple hgweb repos, edit as necessary
# adjust python path if not a system-wide install:
import sys
#input mercurial path
sys.path.insert(0, "/Library/python/2.7/site-packages/mercurial")
sys.path.insert(0, "/Library/python/2.7/site-packages/mercurial")
# enable importing on demand to reduce startup time
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi
application = hgwebdir('hgweb.config')
wsgicgi.launch(application)
make hgweb.config file in the path "/Volumes/works/hg".
and then add the following contents on it.
#hgweb.config
[paths]
#project1 = /Volumes/works/hg/project1
#project2 = /Volumes/works/hg/project2
/ = /Volumes/works/hg/*
[web]
#visiting the given URL paths or including subrepositories
descend = True
allow_push = johnson
#allow_push = *
push_ssl = true
#for http://example.com/hg
baseurl = /hg
#for http://hg.example.com
#baseurl =
if you have only project1 repository, you can define repository's path as like
project1 = /Volumes/works/hg/project1
application = hgwebdir('hgweb.config')
wsgicgi.launch(application)
- hg init
type hg init command for repository.
hg init /volumes/works/hg/"repository name"
- Make hgweb.config
make hgweb.config file in the path "/Volumes/works/hg".
and then add the following contents on it.
#hgweb.config
[paths]
#project1 = /Volumes/works/hg/project1
#project2 = /Volumes/works/hg/project2
/ = /Volumes/works/hg/*
[web]
#visiting the given URL paths or including subrepositories
descend = True
allow_push = johnson
#allow_push = *
push_ssl = true
#for http://example.com/hg
baseurl = /hg
#for http://hg.example.com
#baseurl =
- path
if you have only project1 repository, you can define repository's path as likeproject1 = /Volumes/works/hg/project1
but, if you want to have multiple repositories, do it like this
/ = /Volumes/works/hg/*
so you can access all repositories under /Volumes/works/hg/
ex)
https://example.com/hg/project1
https://example.com/hg/project2
.... and so on.
- allow_push
allow_push = johnsonthis would allow pushing for johnson.
you can allow pushing for everyone as like this
allow_push = *
- Defining User Credential
To make user id and password for mercurial, use htpasswd command.htpasswd -c /Volumes/works/hg/hgusers johnson
(cf htpasswd )
and we have to change permission of repositories.
chown -R _www:_www /Volumes/works/hg
chmod -R g+rw /Volumes/works/hg
chmod -R g+x /Volumes/works/hg
chmod -R g+x /Volumes/works/hg/*
chmod -R g+x /Volumes/works/hg/*/.hg
- Make httpd-hg.conf file
make httpd-hg.conf file in the path /Volumes/works/hg. and add the following text on it.# Mercurial setting
ScriptAlias /hg "/volumes/works/hg/hgweb.cgi"
#restrict pushing to known users
<Location /hg>
#Require SSL authentication
SSLRequireSSL
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /volumes/works/hg/hgusers
Require valid-user
</Location>
- Setting Apache config file
add the following text on /etc/apache2/httpd.conf.
Include /Volumes/works/hg/httpd-hg.conf
and that's all.
if you want to know more or it doesn't work,
please refer to the link.
http://mercurial.selenic.com/wiki/PublishingRepositories
and that's all.
if you want to know more or it doesn't work,
please refer to the link.
http://mercurial.selenic.com/wiki/PublishingRepositories