在《Publishing Mercurial Repositories》这篇文章中介绍了很多种将我们自己的hg代码库发布/公开的办法。其中最轻量型的办法是使用hg自带的web server发布,只需要在代码库目录下执行命令hg serve就搞定。但是这只是一个临时的方案,如果想要更健壮更安全,官网还是建议使用hgweb脚本+Web server(apache,IIS等)的方式。
查看资料后,我权衡利弊,准备以《Serving Mercurial repositories with Apache and mod_wsgi》为蓝本再结合其他教程和实践,来搭建自己的hg server供局域网中的小伙伴使用。
lrwxrwxrwx 1 root root 15 Nov 19 00:50 mod_wsgi.so -> mod_wsgi.so-2.7 -rw-r--r-- 1 root root 152064 Nov 19 00:50 mod_wsgi.so-2.7
<VirtualHost *:80> ServerName hg.example.net DocumentRoot /var/www/vhosts/hg.example.net/htdocs WSGIScriptAliasMatch ^(.*)$ /var/www/vhosts/hg.example.net/cgi-bin/hgweb.wsgi$1 <Directory /var/www/vhosts/hg.example.net/htdocs> Options FollowSymlinks DirectoryIndex index.html AllowOverride None Order allow,deny Allow from all </Directory> <Directory /var/www/vhosts/hg.example.net/cgi-bin> Options ExecCGI FollowSymlinks AddHandler wsgi-script .wsgi AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>第三步,配置Mercurial
# Path to repo or hgweb config to serve (see 'hg help hgweb') config = "/var/www/vhosts/hg.example.net/cgi-bin/hgweb.config" # enable demandloading to reduce startup time from mercurial import demandimport; demandimport.enable() from mercurial.hgweb import hgweb application = hgweb(config)2)hgweb.config
[web] style = coal [paths] / = /var/www/vhosts/hg.example.net/htdocs/**
[collections] /var/hg = /var/hg
好吧,先庆祝一下,下文再说代码提交遇到的问题以及身份认证问题。
参考:
http://mercurial.selenic.com/wiki/PublishingRepositories
http://mercurial.selenic.com/wiki/modwsgi
http://stackoverflow.com/questions/12347373/how-to-setup-mercurial-server-in-ubuntu-to-serve-60-repositories
http://thepanz.netsons.org/post/ubuntu-10-4-and-mercurial-server-apache2-mod_wsgi/comment-page-1
http://blog.sina.com.cn/s/blog_4567bb800100whho.html
http://blog.csdn.net/tony1130/article/details/5326015
http://blog.csdn.net/kongdaoxian/article/details/7944872