How do I prevent someone from pushing multiple heads?

对着背影说爱祢 提交于 2020-01-14 13:00:12

问题


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?


回答1:


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).




回答2:


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



回答3:


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.




回答4:


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.




回答5:


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 ;)]



来源:https://stackoverflow.com/questions/7072580/how-do-i-prevent-someone-from-pushing-multiple-heads

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!