Mercurial§
使用 Unit 安装并运行 Mercurial 源代码控制系统
使用 Python 语言模块安装 Unit。
安装 Mercurial 的 核心文件。此处,我们将其安装在 /path/to/app/;在配置中使用真实路径。
(可选)配置 存储库或选择一个现有的存储库,并记下其目录路径。
Unit 使用 WSGI 运行 Python 应用,因此它需要一个 包装器 脚本来发布 Mercurial 存储库。此处,它是 /path/to/app/hgweb.py(注意扩展名);application 可调用项是入口点
from mercurial.hgweb import hgweb # path to a repo or a hgweb config file to serve in UTF-8 (see 'hg help hgweb') application = hgweb("/path/to/app/repo/or/config/file".encode("utf-8"))
这是一个非常基本的脚本;要对其进行详细说明,请参阅 Mercurial 存储库发布 指南。
运行以下命令,以便 Unit 可以访问 应用程序目录
# chown -R unit:unit /path/to/app/
有关更多详细信息,包括权限,请参阅 安全检查清单。
接下来,为 Unit 准备 Mercurial 配置(对 path 使用真实值)
{ "listeners": { "*:80": { "pass": "applications/hg" } }, "applications": { "hg": { "type": "python", "path": "/path/to/app/", "module": "hgweb" } } }
上传更新的配置。假设上面的 JSON 已添加到
config.json
# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock http://localhost/config/
成功更新后,您可以继续照常使用 Mercurial 存储库
$ hg config --edit $ hg clone http://localhost/ project/ $ cd project/ $ touch hg_rocks.txt $ hg add $ hg commit -m 'Official: Mercurial on Unit rocks!' $ hg push