if [ ! $1 ];then echo '请输入版本库名称' exit else repos_name=$1 repos_url='svn://code.domain.com/'$repos_name repos_dir='/root/svn_co_code/'$repos_name trunk=$repos_url'/trunk' dev=$repos_url'/branches/dev' trunk_ver=$(svn info ${trunk} -rHEAD | grep "最后修改的版本:" | cut -d' ' -f2) if [ ! $trunk_ver ];then echo '版本库不存在' exit fi if [ ! -d $repos_dir ];then cd /root/svn_co_code svn co $repos_url fi dev_ver=$(svn info ${dev} -rHEAD | grep "最后修改的版本:" | cut -d' ' -f2) echo '主干分支版本号(trunk):'$trunk_ver echo '开发分支版本号(branches/dev):'$dev_ver if [ $trunk_ver -ge $dev_ver ];then echo '无需合并' exit fi cd $repos_dir pwd svn up cd $repos_dir'/trunk' svn merge -r $trunk_ver:$dev_ver $dev svn ci -m "merge br dev@${dev_ver} to trunk" pwd svn log -v -l1 fi