linux svn版本比较
#!/bin/sh #导出指定版本之间的差异文件 如100到200之间的差异则导出100(不包括)-200(包括)的所有修改 SVN_URL="svn://192.168.1.127/porject" if [ $# -eq 0 ] ; then echo "You must useage like $0 old_version1(不包括) new_version(包括)" exit 1 fi if [ $1 -gt $2 ] ; then echo "You must useage like $0 old_version1(不包括) new_version(包括)" exit 1 fi OLD_VERSION=$1 NEW_VERSION=$2 #导出的目标路径 WORK_PATH="/app/htdocs/project" echo "开始分析版本差异..." DIFF_URL="svn diff -r ${OLD_VERSION}:${NEW_VERSION} --summarize --username bug --password 123456 ${SVN_URL}" echo ${DIFF_URL} if test ! -e "${WORK_PATH}"; then mkdir -p ${WORK_PATH} fi #echo ${DIFF_URL}|sh >${WORK_PATH}_diff.txt DIFF_NUM=`${DIFF_URL} |wc -l` if [ ${DIFF_NUM} -ne 0 ]; then echo "差异文件共${DIFF_NUM}个,准备导出." DIFF_LIST=`${DIFF_URL}` #echo ${DIFF_LIST} NUM=0 SKIP=0 for FIELD in ${DIFF_LIST} ; do #长度小于3(A、M、D、AM即增加且修改)即是更新标识,否则为url if [ ${#FIELD} -lt 3 ]; then let NUM+=1 SKIP=0 if [ "${FIELD}" == "D" ]; then #下一个应该跳过 SKIP=1 fi continue fi #若为删除文件则不必导出 if [ ${SKIP} -eq 1 ]; then echo ${NUM}.'是删除操作,跳过:'${FIELD} continue fi #替换得到相对路径 DIFF_FILE=${FIELD//${SVN_URL}/} echo ${NUM}.' '${DIFF_FILE} FILE_NAME=`basename ${DIFF_FILE}` FOLDER_NAME=`dirname ${DIFF_FILE}` FOLDER_PATH="${WORK_PATH}${FOLDER_NAME}" #echo ${FILE_NAME}' '${FOLDER_NAME}' '${FOLDER_PATH} if test ! -e "${FOLDER_PATH}"; then mkdir -p ${FOLDER_PATH} fi CMD="svn export -r ${NEW_VERSION} '${SVN_URL}${DIFF_FILE}' '${FOLDER_PATH}/${FILE_NAME}' --force" #echo ${CMD} #echo ${NUM}.' ' echo ${CMD}|sh done echo -e "版本号:"${OLD_VERSION}"->"${NEW_VERSION} "\t时间:" $(date +"%Y-%m-%d %H:%M:%S")>> /app/svndata/push_logs.txt echo "完成" else echo "版本间没有差异" fi
publish.sh 用法
比较两个版本差异
publish.sh old_version new_version
publish.sh 2055 2056