开发者

How do I prevent someone from pushing multiple heads?

I have colleagues who push multiple heads by using the --force switch because they haven't 开发者_如何学编程merged properly.

Are there any ways to prevent this?


You can do this with a pretxnchangegroup hook on the server side.

Here are a few examples: http://www.softwareprojects.com/resources/programming/t-mercurial-hook-forbid-2-heads-1910.html

All those hooks are doing is making sure that after the changegroup is applied that there's still only one head (or only one per branch if you want to get fancy).


Tell them they shouldn't do it, and enforce the workflow with hooks on a repository you control.

At work, we restrict it to one head / branch. Essentially replace forbid_2head.sh with this:

#!/bin/bash

# Ensure only one head per branch in hg repository
for BRANCH in `hg branches -qa`
do
    COUNT=`hg heads -q $BRANCH | wc -l`
    if [ "$COUNT" -ne "1" ] ; then
       echo "Error: Trying to push more than one head to branch $BRANCH."
       exit 1
    fi
done
exit 0


This is the best from top proficient developers: http://hg.python.org/hooks/file/default/checkheads.py

Visit http://hg.python.org/hooks/file/default/ for list of another useful hooks.


You could revoke their push rights to the repository that they are --forceing to, and make them push to a different server, or submit changes via patch.


First off, I'd tell developers that a --force push is not allowed.

I'd also use the server side hook solution as prescribed above, and in the hook add an email to everyone stating WHO tried to push multiple heads into the central repo [and then format his hard drive ;)]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜