我正在运行中央 mercurial 存储库,我知道如果远程用户试图将多个“头”强制连接到我的中央存储库,则正常的“推送”命令将停止。目的是远程用户在尝试再次推送之前应该先拉取和合并。
但是,使用hg push --force将覆盖它。我想阻止这种行为。
我目前正在使用hgwebdir.cgi加上一些 apache-auth 的东西来限制用户拉和推的能力。
编辑:一个 pretxnchangegroup 钩子解决了这个问题。钩子工作:
#!/bin/bash
# force-one-head
# add the following to <repository>/.hg/hgrc :
# [hooks]
# pretxnchangegroup.forceonehead = /path/to/force-one-head
if [[ `hg heads -q | wc -l` -gt 1 ]]; then
echo "There are multiple heads."
echo "Please 'hg pull' and get your repository up to date first."
echo "Also, don't 'hg push --force' because that won't work either."
exit 1
fi
Run Code Online (Sandbox Code Playgroud) 我们将需要托管一系列 Mercurial 存储库。为了安全起见,我们将在 Apache 中使用 SSL 加密和 htpasswd 访问(必需)。我测试了一个存储库并使用hgwebdir.cgi和hgweb.config来定义存储库路径allow_push和deny_push指令,但是这个测试设置只会导致更多的问题/问题:
我没有看到任何方法可以为每个单独的存储库创建不同的允许/拒绝推送组?更重要的是,我看不到任何方法allow_pull deny_pull——这非常重要,因为每个存储库都有一组不同的用户,他们应该被允许读或写。我们希望htpasswd为所有用户保留一个文件。