Practical SVN trunk Trunk Auto Merge to each branch branch script

Source: Internet
Author: User

practical svn trunk Trunk Auto Merge to each branch branch script

Most companies that use SVN, when they find bugs or new features, generate a branch branch directly from the trunk trunk, such as BUG01. Then colleague a modifies the bug inside, if the test passes, commits the branch, merges the branch bug01 into the trunk, and resolves the conflict and the skeleton remains consistent. Colleague B also pulls a branch bug02, he also modifies, also tests through, commits the branch, merges the branch bug02 into the trunk, and resolves the conflict and the trunk remains consistent. Theoretically there is no problem.

problem Now
But there is a situation where a colleague, A, commits the branch after the modification, merges into the trunk to resolve the conflict, modifies N times, and colleague B commits the modification and does not merge into the branch. Modified n times. Suddenly one day, colleagues want to merge into the trunk when found N multiple conflict, bug02 and branch farther away, do not know where to solve.

Solution Ideas
is to let the branch not be too far from the trunk , the trunk automatically close to the branch, no conflict is found to merge, found the conflict, on the revert restore branch, send the conflict details of the mail, manual processing. Do the timing, if not processing, will always send mail.

with the script
The script sends the message with SendEmail, not sendmail. is foreignBrandon written in Perl, easy to use and powerful. This is designed for use in PHP, Bash, Perl, and Web sites.
Official website:Http://caspian.dotconf.net/menu/Software/SendEmail/
no crap, look at the script:

#!/bin/bash#write: lijing qq 858080796#date:  20160722 v1.0#description: Merge svn trunk to branch, no conflict, then merge, conflict, cancel merge, and revert  and   alarm (mail). #定义变量source  /etc/profiledate=$ (date  "+%f %h:%m") sendemail=/usr/src/sendemail#        define the outgoing mail program svn_work_root=/ data/everyday_co_itnanbksvn#        definition download to local SVN replica directory error= "" AUTH_UP= "-- Username=lijing  --password=lijing "  #        define authentication account Svn_ Url= "Http://svn.itnanbk.com/tcw/code/PHP" #定义SVN地址LOG =/tmp/.merge.log# defined with and without conflict log smslog=/tmp/.sms.log# Mail message mailuser= "[email protected]" #定义函数 # definition Display color green () {        echo  -e  "\033[01;32m  ' Date ' $1 \033[0m\n"           Retval= "0"     }red () {        echo -e  "\ 033[01;31m  ' Date ' $1 \033[0m\ n "         retval=" 1 "} #从版本库检出 (checkout) to local working copy CO_SVN ()  { srcdir=$1dstdir=$2                  #下到本地2次cd   $SVN _work_root/$SRCDIR  && svn  co  $AUTH _up  $SVN _url /$SRCDIR   .  && Green  "checkout  $SVN _url/$SRCDIR  success"  | |  Red  "checkout  $SVN _url/$SRCDIR  failed "  cd  $SVN _work_root/$DSTDIR   && svn  co  $AUTH _up  $SVN _url/$DSTDIR   .&& Green  " checkout  $SVN _url/$SRCDIR  success " | |  Red  "checkout  $SVN _url/Directory Contents list_svn ()  {srcdir=$ $SRCDIR  failed "} #列出 (list) repository 1dstdir=$2                # List content assignment to svnlist       svnlist=$ (Svn list  $AUTH _up  $SVN _url/$DSTDIR)  && Green  "list  $SVNLIST  success"  | |  Red  "list   $DSTDIR  failed"} #将版本库的修改更新 (update) to the local working copy UPDATE_SVN ()  {srcdir=$ 1dstdir=$2                # Updated 2 times cd  $SVN _work_root/$SRCDIR  &&  svn update --force  $AUTH _up   && Green  "update   $SVN _work_root/$SRCDIR   success"  | |  Red  "update   $SVN _work_root/$SRCDIR   failed" cd  $SVN _work_root/$DSTDIR  &&  svn update --force  $AUTH _up  && green  " update   $SVN _work_root/$SRCDIR   success " | |  Red  "update   $SVN _work_root/$SRCDIR   failed"} #合并 (merge) changes to local working copy       MERGE_SVN ()  {srcdir=$1dstdir=$2                 #执行合并echo   "Svn merge   $AUTH _up --non-interactive  $SVN _url/$SRCDIR "cd  $SVN _work_root/$DSTDIR/$SL  &&    svn merge  $AUTH _up  --non-interactive  $SVN _url/$SRCDIR  |tee   $LOG   && Green  "merge   $DSTDIR/$SL  success" | |  Red  "merge   $DSTDIR/$SL  failed"}#        Commit the modification of the local working copy (commit) to the Repository      ci_svn ()  {SRCDIR=$1DSTDIR=$2                  #执行提交echo   "Svn ci   $AUTH _up  $SVN _url/$SRCDIR "cd  $SVN _work_root/$DSTDIR/$SL  &&   SVN  ci  $AUTH _up  -m  "$DATE   Auto merge   $SRCDIR   to branch  /$DSTDIR/$SL"    && Green  "commit   $DSTdir/$SL  success " | |  Red  "commit   $DSTDIR/$SL  failed"} #将工作副本文件恢复 (revert) to the original version (restores most of the local modifications). REVERT_SVN ()  {SRCDIR=$1DSTDIR=$2                  #执行还原cd   $SVN _work_root/$DSTDIR/$SL  &&  svn revert  -R ./*   $AUTH _up  && green  "revert   $DSTDIR   Success " | |  Red  "revert   $DSTDIR  failed"} #如果有冲突, email alert (sendmail) SendMail () {srcdir=$1dstdir=$2                  #替换 $SMSLOG in the log "Recovered" as "conflict Details", "-"   "XX"  sed -i  ' s/restored/conflicting details/g '   $SMSLOG  |sed   ' s/\-\-\-/ Xxx/g ' |sed   ' s/\-\-/xx/g '                   #执行发邮件sms =$ (cat  $SMSLOG)         [ -z  "$sms"  ] && exit  $SENDEMAIL  -s smtp.itnanbk.com -f  [email protected]                               -t   $MAILUSER                               -xu [email protected]  -xp  ' itnanbk2015 '                                         -u  "Big x Network svn merge  conflict"                                 -o message-content-type=auto                               -o message-charset=utf-8                               -m   "$sms"}green  "... write: lijing qq 858080796&nbsp", "green ", ......... ............. Starting merge SVN trunk to branch, no conflict, then merge, conflict, cancel merge, and revert  and   alarm (mail) ... "#主程序 # empty the log echo > $ smslog# the main project trunk to the branch branch, and sys_admin the console project to a branch under Admin_branch. Needmerge= "Trunk sys_admin" for needmerge in  $NeedMerge  ;d o[ -n  "$NeedMerge"  ] && [  "$NeedMerge"  =  "Sys_admin"  ] && srcdir= sys_admin dstdir=admin_branch  | |   srcdir=trunk dstdir=branchecho -e  "  $NeedMerge  \n" echo  $SRCDIRecho   $DSTDIRCD   $SVN _work_root/$DSTDIR  && rm -rf  $SVN _work_root/$DSTDIR/*echo >   $LOGecho  -e   \n  $DATE   $SRCDIR   merging to   $DSTDIR   the details of each branch are as follows:  \n   " >>  $SMSLOG  echo " Update the local copy &nbsp ... "update_svn   $SRCDIR."   $DSTDIRecho   "Download new version update to local &nbsp ..." co_svn  $SRCDIR   $DSTDIRecho   "List contents in directory   ... "list_svn   $SRCDIR   $DSTDIR        FOR SL---  in   $SVNLIST  ;d o                 echo ..................................         echo  "ready to merge to $dstdir/$SL" merge_svn  $SRCDIR   $DSTDIRcat   $LOG  |grep -qE  " Conflict Summary | Summary of confLicts "&& Green " merged with conflict, failed "  | |  Red  Merge no conflict, success  cat  $LOG  |grep -qE  Conflict Summary | Summary of conflicts "   | |  echo -e  "No conflicts, submit merge to  SVN  server  \n"   && CI_SVN  $SRCDIR   $DSTDIR  && Green  "No conflict, submit merge $srcdir  to   $DSTDIR  SVN server, Success" cat $ log |grep -qe  "Conflict Summary | Summary of conflicts "   && echo -e "  \n   Discovery Conflict:    Big x network svn  $SRCDIR  merge to   $DSTDIR/$SL   conflict   \n   " >>   $SMSLOG   && cat  $LOG |grep -e  -v  "^a|^d|^m|^g|^u|^r|^i|^ \ g|^ u|^--" >>   $SMSLOG  cat  $LOG  |grep -qE " Conflict Summary | Summary of conflicts "   && echo " Discovery Conflict, execution revet: \n " & & revert_svn  $SRCDIR   $DSTDIR  donedone        grep -q  "conflicts"    $SMSLOG   && echo  Execute outgoing mail: \n    &&  sendmail  $SRCDIR   $DSTDIR



Finally, attach a copy of the Foxmail
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/04/wKiom1fRNeijWQqXAAD8MbqCL9Y602.jpg-wh_500x0-wm_3 -wmp_4-s_2290327056.jpg "title=" merge.jpg "alt=" Wkiom1frneijwqqxaad8mbqcl9y602.jpg-wh_50 "/>

This article is Clever unfeeling A word a graph out, referring to a lot of information, thanks to their sharing, based onOpen Sourceshare the Spirit, reprint please indicate out.
support me, please Force Click Clever unfeeling Thanks

Resources:

http://caspian.dotconf.net/menu/Software/SendEmail/


This article is from "clever unfeeling-li jing" blog, please make sure to keep this source http://qiaomiao.blog.51cto.com/484197/1850829

Practical SVN trunk Trunk Auto Merge to each branch branch script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.