【发布时间】:2012-10-09 11:35:26
【问题描述】:
作为Mercurial: enforce "hg pull -u" before "hg commit" 的后续行动 我已经开始使用钩子了
[hooks]
pretxnchangegroup.forbid_2heads = /usr/local/bin/forbid_2head.sh
forbid_2head.sh 看起来像这样
#!/bin/bash
BRANCH=`hg branch`
COUNT=`hg heads --template '{branch}|{rev}\n' | grep ^${BRANCH} | wc -l`
if [ "$COUNT" -ne "1" ] ; then
echo "=========================================================="
echo "Trying to push more than one head, which is not allowed"
echo "You seem to try to add changes to an old changeset!"
echo "=========================================================="
exit 1
fi
exit 0
它是在http://tutorials.davidherron.com/2008/10/forbidding-multiple-heads-in-shared.html 找到的脚本的派生 我确实允许多个命名分支。
我现在的问题是
- 它停止了我想要的 hg push -f
- 如果有传入的变更集并且我有提交传出,它也会停止 hg pull。这确实很糟糕
我可以以任何方式重复使用相同的脚本,但更改挂钩设置并停止“hg push -f”吗? 或者我可以在 forbid_2head.sh 中知道这是在运行 push 还是 pull 命令?
【问题讨论】: