我正在寻找信息来build立与Windows(7或XP)与Mercurial服务器与Apache(xampp,如果这是有用的知道它)推模式,就像在这个问题,但我的团队是由5至8 (unsolvent)的人,他们每个人都在不同的地方工作,所以我不认为bitbucket解决scheme或其他非私人的回购。
我觉得这个post会做的伎俩,但我没有经历任何与cgi之前,
有没有人做过这个? 我在哪里可以find更详细的解释? 提前致谢
[编辑]
我现在得到这个错误:脚本头的过早结束:hgwebdir.cgi
日志错误说“没有名为mercurial的模块”
这是我的hgwebdir.cgi文件
#!c:/python24/python.exe # # An example CGI script to export multiple hgweb repos, edit as necessary # adjust python path if not a system-wide install: import sys sys.path.insert(0, "c:/mercurial_library") # enable importing on demand to reduce startup time from mercurial import demandimport; demandimport.enable() # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb #cgitb.enable() # If you'd like to serve pages with UTF-8 instead of your default # locale charset, you can do so by uncommenting the following lines. # Note that this will cause your .hgrc files to be interpreted in # UTF-8 and all your repo files to be displayed using UTF-8. # #import os #os.environ["HGENCODING"] = "UTF-8" from mercurial.hgweb.hgwebdir_mod import hgwebdir import mercurial.hgweb.wsgicgi as wsgicgi application = hgwebdir('hgweb.config') wsgicgi.launch(application)
我使用了HgWebDir指令 :
这是我的httpd.conf部分mercurial网站(稍作编辑):
<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:
我也不得不打开几个Auth Digest模块
我把hgwebdir.cgi放在公共和私人文件夹的根目录下,然后把我的每个hg repos放在repos子文件夹下的适当文件夹下。
Apache认证负责我的授权。
然后我只是把hgweb.config文件放在这样的位置:
[collections] repos = repos [web] allow_archive = bz2 gz zip style = gitweb baseurl = /public
更新了问题
mercurial包需要在PYTHON_PATH上
这个答案给出了更多细节。
John Weldons的回答是正确的,我只是想提供一些关于你可能感兴趣的各种可能性的细节。
hgwebdir只是一个wsgi应用程序,所以你可以像在apache2中使用mod_wsgi的其他wsgi应用程序一样运行它。 mod_wsgi也会比cgi执行更好,因为加载python解释器的开销是一次完成的,而不是每个请求。
另外由于是一个wsgi应用程序意味着你也可以把它包装在中间件 ,或挂起更大的网站等另一个网址 …
例如,假设您正在使用trac (另一个wsgi应用程序),并且想要在trac和hgwebdir之间共享授权方案,则可以通过将它们同时放在授权中间件(如repoze.who)之后来完成。
最后,由于python粘贴使构建web应用程序的小块,我写这个代码片段通过粘贴启动hgwebdir。
""" 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)
和相应的配置文件部分来加载它…
[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
我发现这个博客文章特别有用: http : //blog.riverside-software.fr/2011/02/quick-and-easy-setup-of-mercurial.html 。
这很简单,在不到15分钟的时间里让我上班。