我们团队使用hg(Mercurial)的方式是主分支模式,所有人都从主分支上检出代码,修改后提交到以自己名字命名的分支,然后和主分支合并(master -> mybranch),解决冲突.然后再合并到主分支(mybranch -> master).
鉴于团队中对hg的掌握程度不同,我特别的写了一个脚本来实现提交改动的自动化.
此脚本可以在linux中运行,直接放到hg项目的目录中执行即可.
#!/bin/sh
branch=`hg branch`
if [ $# -ne 1 ]; then
echo "Usage: ${0} branch_name"
exit
fi
select(){
read -p "你确定要在 ${branch} 分支上提交么?[y/n]:" confirm
if [ ${confirm} ]; then
if [ ${confirm} = "y" ]; then
hg ci
else
if [ ${confirm} = "n" ]; then
echo "请更新到你的分支后再提交。"
exit
fi
select
fi
else
echo "请更新到你的分支后再提交。"
exit
fi
}
if [ ${branch} != $1 ]; then
select
hg up "$1"
if [ $? -ne 0 ]; then
echo "请检查命令参数 branch_name"
exit
fi
fi
hg pull
hg merge beta
if [ $? -ne 0 ]; then
echo "请提交未提交的改动!"
select
hg merge beta
fi
hg ci -m "beta -> ${branch}"
hg up beta
hg merge $branch
hg ci -m "${branch} -> beta"
hg push
hg up ${1}
if [ $? -ne 0 ]; then
exit
fi
echo "完成!"

本文介绍了如何通过一个自动化脚本简化Mercurial版本控制系统中的提交流程,适用于团队中成员对Mercurial掌握程度不同的场景。脚本允许用户在特定分支上提交更改,并自动处理分支间的合并,提高开发效率。
5011

被折叠的 条评论
为什么被折叠?



