#!/bin/bashFROM=$1REVISION=$2AUTOCOMMIT=$3if["$FROM"=""]||["$REVISION"=""]thenecho"Usage: $0 <from version> <changeset> [autocommit]"exit2filocalchanges=`svnstat|wc-l`if["$localchanges"!="0"]thenecho"You must have a clean working space copy"exit2fiif["$SVN_PASS_FILE"!=""]thenSVN_PASS=`cat"$SVN_PASS_FILE"`fi
svnup
currentrepowithoutversion=`svninfo|grepURL|sed"s/URL: //"|sed"s/\/[^\/]*$//"`sourceurl="$currentrepowithoutversion/$FROM"msg=`svnlog$sourceurl-r$REVISION--xml|grep"<msg>"|sed"s/<msg>//"|sed"s/<\/msg>//"`
svnmerge$sourceurl.-c$REVISIONif["$?"!="0"]thenecho"Merge failed. Conflicts must be resolved manually!"exit3fimsg="[merge from $FROM] $msg"if["$AUTOCOMMIT"="autocommit"]thenecho"Trying to commit..."if["$SVN_USER"!=""]thensvncommit-m"$msg"--username$SVN_USER--password$SVN_PASSelsesvncommit-m"$msg"fiRET=$?if["$RET"!="0"]thenexit1fiexit0elseecho"Run the following command to commit..."echosvncommit-m\"$msg\"exit1fi