通过VisualSVN Server托管Mercurial HG

5
我尝试使用Scriptalias托管Mercurial HG仓库。
ScriptAlias /hg/ "htdocs/hgwebdir.cgi"
在Chrome中,它会显示cgi文件的内容。在IE中,它确实可以渲染,但是图片和链接没有显示出来。无论哪种情况,我想要显示的仓库都没有显示出来。
有人成功使用VisualSVN吗?如果我启用了Windows身份验证和https,这个方法还能行得通吗?

我已经试图解决这个问题两天了!但愿我有一个答案。 - Dave Neeley
在ScriptAlias的最后一个参数中,您必须使用绝对路径。 - Graham Dumpleton
4个回答

6
这里有一个使用mod_wsgi(快速!)和合并存储库目录的备选设置,您可以从VisualSVN Server GUI管理Mercurial存储库级别的访问。请下载Apache 2.2 Win32的mod_wsgi.so并放置在“C:\ Program Files \ VisualSVN Server \ bin”中。将hgwebdir.wsgi从您的Mercurial安装(contrib目录)复制到“C:\ Program Files \ VisualSVN Server \”中。它应该看起来像这样:
import sys
sys.path.insert(0, "C:\Program Files\Mercurial\library")
from mercurial.hgweb.hgwebdir_mod import hgwebdir
application = hgwebdir('hgweb.config')

创建配置文件"C:\Program Files\VisualSVN Server\hgweb.config"。
[paths]
/ = c:/Repositories/*

将以下内容粘贴到"C:\Program Files\VisualSVN Server\conf\httpd-custom.conf",您应该根据httpd.conf的部分调整Auth*值。

LoadModule wsgi_module bin/mod_wsgi.so
WSGIScriptAlias /hg "hgwebdir.wsgi"

<Location /hg/>
    AuthName "Mercurial Repositories"
    AuthType VisualSVN
    AuthzVisualSVNAccessFile "C:/Repositories/authz-windows"
    AuthnVisualSVNBasic on
    AuthnVisualSVNIntegrated off
    AuthnVisualSVNUPN Off

    SVNParentPath "C:/Repositories/"

    require valid-user
</Location>

创建一个 Mercurial 代码库:
hg init C:\Repositories\hgtest

现在您应该可以通过浏览器访问/hg,并通过VisualSVN Server工具管理存储库级别的授权。


我觉得我离让它工作非常接近了,但是我遇到了一个错误:'Exception occurred processing WSGI script mercurial',以及"File "mercurial\hgweb\hgwebdir_mod.pyc", line 103, in call"。最新的Mercurial 1.5.1是否已经针对Python 2.6编译了? - dvkwong
发布上一个评论5秒后,我终于让它工作了!按照之前的回答,将“模板”文件夹复制到“库”文件夹中。需要跟随的额外步骤:
  1. 在Mercurial安装中提取libraries.zip到名为libraries的文件夹中。
  2. 将“模板”文件夹复制到“库”文件夹中。
  3. 确保您安装了Python 2.6。
谢谢!
- dvkwong
1
FYI:自3.3.0版本以来,VisualSVN Server发行版中已包含mod_wsgi模块:https://www.visualsvn.com/server/changes/#v3.3.0 - Ivan Zhakov

2
假设您已经安装并成功使用Python 2.6,以下是我所采取的步骤。
获取为Apache 2.2 Win32构建的"mod_cgi.so",并将它放置在"C:\Program Files\VisualSVN Server\bin"中。
将以下内容粘贴到"C:\Program Files\VisualSVN Server\conf\httpd-custom.conf"中。
LoadModule cgi_module bin/mod_cgi.so
ScriptAliasMatch ^/hg(.*) "cgi-bin/hgweb.cgi$1"

创建 "C:\Program Files\VisualSVN Server\cgi-bin" 目录,并将 hgweb.cgi 文件放入其中。确保它看起来与以下内容类似:
#!c:/Python26/python.exe -u

import sys
sys.path.insert(0, "C:\Program Files\Mercurial\library")

import cgitb
cgitb.enable()

from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi

application = hgwebdir('hgweb.config')
wsgicgi.launch(application)

在cgi-bin目录中创建名为hgweb.config的文件。
[paths]
/ = c:/HgRepositories/*

将"C:\Program Files\Mercurial\templates"复制到"C:\Program Files\Mercurial\library\templates"。

创建"C:\HgRepositories"文件夹和"hg init c:\HgRepositories\test"。

重新启动VisualSVN服务器,打开浏览器,享受您的Mercurial存储库。


0
从Mercurial 1.6版本开始,hgwebdir.wsgi脚本已经与hgweb.wsgi脚本合并。在这些说明中提到hgwebdir.wsgi的地方,您可以替换为hgweb.wsgi脚本。

https://www.mercurial-scm.org/wiki/modwsgi


-1

只要您的Web服务器在将REMOTE_USER变量移交给CGI之前处理它们,您就可以在不同的身份验证和https模块后面运行hgwebdir。

我不了解visualsvn,但是您的ScriptAlias看起来很像Apache。您是否需要为.cgi添加AddHandler行?


那个AddHandler行是不是在常规的Apache服务器上执行CGI所需的全部内容? - Dave Neeley
在Apache中,您可以使用“ExecCGI”、“AddHandler cgi-script .cgi”和“ScriptAlias”来授权执行文件。我使用后两个。 - Ry4an Brase

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接