通过HTTP安装mercurial

你可以给一些指针设置通过HTTP / HTTPS Mercurial? 我正在设置一个开发服务器(Debian),在那里我想创build一个mercurial仓库,并将更改推送到服务器。 我需要进行身份validation,以防止任何不必要的访问。

提前致谢。

我认为Apache是​​共享hg仓库的好方法。 hgweb.wsgi脚本不仅提供了运行多个存储库的可能性,还允许开发人员通过path或修订,从源代码中方便地交叉引用项目源代码。

以下过程将提供一种发布存储库的简单方法,并通过https Web连接将其提供给经过身份validation的用户。

首先我build议制作一个没有本地文件目录的repo的克隆。

hg clone -U <myproject> <myproject_to_serve> 

接下来(使用WSGIconfiguration,这很容易),请执行以下操作:

将您的回购移到一个方便的地方,从中提供服务:

 mv <myproject_to_serve> /var/www/hg/<myproject_to_serve> 

确保Web服务器用户可以读取/写入repo:

 chown -R www-data:www-data /var/www/hg/<myproject_to_serve> 

现在为项目用户设置读/写权限,并在服务器主页上提供项目列表的一些信息:

 vim /var/www/hg/myproject_to_serve>/.hg/hgrc [web] description = 'This is my new web-enabled project <myproject>' contact = [email protected] # consider limiting push usage to only a subset of users allow_push = * 

现在安装WSGI

 vim /var/www/hg/hgweb.config [paths] /myproj = /var/www/hg/my_project_to_serve 

现在设置Apache

 <VirtualHost *:443> ServerName hg.mydomain.net ServerAdmin [email protected] ErrorLog /var/www/mydomain/logs/hg_error_log CustomLog /var/www/mydomain/logs/hg_access_log common SSLEngine on SSLCertificateFile /etc/ssl/mydomain_net.crt SSLCertificateKeyFile /etc/ssl/mydomain_net.key DocumentRoot "/var/www/hg/" <Location "/hg"> SetHandler None </Location> # path to provided hgweb.wsgi script WSGIScriptAlias / /var/www/hg/scripts/hgweb.wsgi <Location / > AuthType Digest AuthName "MySoftware" AuthUserFile /home/software/software_web_permissions Require valid-user </Location> </VirtualHost> 

以上要求你有:

  1. hgweb.wsgi脚本(附带一个标准的Mercurial安装在Debian上)可以方便地使用
  2. apache htdigest格式的AuthUserFile,用于创build经过身份validation的用户。

冲浪到hg.mydomain.net会显示一个很好格式化的可用项目列表。 根据/var/www/hg/<myproject_to_serve>回购, hg.mydomain.net/myproj将在成功validation后向您显示您的项目的当前状态。

mercurial wiki上提供了一个相当不错的选项总结,以及优势/劣势。

我的build议是,如果你真的不需要任何types的networking接口,那就是使用ssh作为传输协议。 它甚至不需要真正的configuration,只需要安装ssh和Mercurial。

例如:要将位于~username/hgtest名为hgtest的远程repo克隆到当前目录中,请使用命令

 hg clone ssh://[email protected]/hgtest