base_merge_files="" for f in$merge_files; do if [[ $base_merge_files == "" ]]; then base_merge_files=$(basename $f) else base_merge_files="${base_merge_files}$(basename $f)" fi done
if [ "$base_merge_files" != "" ]; then echo"==>START MERGE ${version} [${base_merge_files}]" for f in${merge_files}; do svn_cmd=$(expr substr $f 1 1) f=$(echo$f | sed -e "s/^.//" | sed -e "s/${SRC_SVN_URL_BASE}//" | sed -e "s/\/\//\//g" | sed -e "s/\/\//\//g") local_f=".$f" case$svn_cmdin A) tmp="svn copy --username ${SVN_USER} --password ${SVN_PASS} -r $version${SRC_SVN_URL}$f$local_f" ;; M) ## tmp="svn merge --username ${SVN_USER} --password ${SVN_PASS} -r $((version-1)):$version --ignore-ancestry ${SRC_SVN_URL}$f $local_f" tmp="svn merge --username ${SVN_USER} --password ${SVN_PASS} -c $version --ignore-ancestry ${SRC_SVN_URL}$f$local_f" ;; D) tmp="svn del $local_f" ;; *) echo"暂不支持的命令" exit ;; esac ttmp=$($tmp) if [ $? -ne 0 ]; then echo" [FAIL]$ttmp" exit else echo" [SUCCESS]$f" fi done
if [ $# -eq 0 ]; then echo"---------------------" echo"$0 version1:version2 version3 " echo"---------------------" exit fi
whiletrue; do if [ $# -eq 0 ]; then break else
## 确保文件存在 touch ${MERGE_SUCCESS_VERSION} touch ${MERGE_SUCCESS_COMMENT} ## 获取版本 f_version=$(echo$1 | cut -d : -f 1) t_version=$(echo$1 | cut -d : -f 2) for version in $(seq $f_version$t_version); do ## 是否已经合并成功 is_merge_success=0 for v in $(cat ${MERGE_SUCCESS_VERSION}); do if [ "${v}" == "$version" ]; then is_merge_success=1 fi done if [ $is_merge_success -eq 0 ]; then svn_merge_one $version fi done fi shift done
DEST_DIR_LIST="" functionfind_branch_list(){ MIN_VER=$1 echo"��Ѱ >=$MIN_VER �汾�ķ�֧ ..." stable_dir=$(svn list $SVN_BASE_URL$SVN_PARAM | grep trunk_.*_s) for i in${stable_dir[@]}; do echo"�����ȶ���: $RELATIVE_DIR/$i" DEST_DIR_LIST="$DEST_DIR_LIST$RELATIVE_DIR/$i" done
branch_dir=$(svn list $SVN_BASE_URL$SVN_PARAM | grep branch_.*) for i in${branch_dir[@]}; do for j in $(svn list $SVN_BASE_URL/$i$SVN_PARAM); do ver=$(echo$j | grep -Eo '[0-9]+') if [[ "$ver" == "" ]]; then ver=0 fi if [ "$ver" -ge "$MIN_VER" ]; then echo"���ַ�֧: $RELATIVE_DIR/$i/$j" DEST_DIR_LIST="$DEST_DIR_LIST$RELATIVE_DIR/$i/$j" fi done done }
## �ϲ�һ����֧ functionsvn_merge_one(){ dest_dir=$1 version=$2 ## �������ɵ�ַ dest_dir="$(dirname $dest_dir)/$(basename $dest_dir)" if [ ! -d "${dest_dir}" ]; then svn_dir=$(basename $(dirname ${dest_dir}))/$(basename ${dest_dir}) svn co $SVN_PARAM${SVN_BASE_URL}/$svn_dir$dest_dir fi echo"����Ŀ¼: ${dest_dir}" && cd$dest_dir && svn up TortoiseProc /command:merge /fromurl:$SRC_SVN_URL /revrange:${version/:/-} /path:"*" /closeonend:1 TortoiseProc /command:commit /path:"*" /closeonend:1 }
BRANCH_VERSION=$1 SVN_VERSION=$2 if [[ "$BRANCH_VERSION" == "" || "$SVN_VERSION" == "" ]]; then help else find_branch_list $BRANCH_VERSION svn_merge ${SVN_VERSION} fi