根据列表拷贝文件和对比,以及SVN提交

1.根据列表拷贝文件

#!/bin/sh

if [ $# -lt 2 ]; then
    echo "Usage: ${0} fileList source_path output_path"
    exit 9
fi

fileList=$1
source_path=$2
outputpath=$3

echo ${source_path}

for file in `cat ${fileList}`
do
    thisfile=`echo $file|cut -d@ -f1`
    bname=`basename $thisfile`
    thisdir=`dirname $thisfile`
    source_path2=${source_path}"/"${thisdir}
    destpath=${outputpath}${thisdir}

    echo -e "\n\n"
    echo "##### handling  ${file} #####################################################"
    echo "##### will copy to ${destpath}/${bname}"

    echo "cp ${source_path2}"/"${bname} ${destpath}"/"${bname}"
    mkdir -p ${destpath}
    cp ${source_path2}"/"${bname} ${destpath}"/"${bname}
    
    echo "##### done!!!!  ${file} #####################################################"
done

2.根据列表文件对比

#!/bin/sh
if [ $# -lt 2 ]; then
    echo "Usage: ${0} fileList source_path other_path"
    exit 9
fi

fileList=$1
source_path=$2
outputpath=$3
result=0

echo ${source_path}

for file in `cat ${fileList}`
do
    thisfile=`echo $file|cut -d@ -f1`
    bname=`basename $thisfile`
    thisdir=`dirname $thisfile`
    source_path2=${source_path}${thisdir}"/"
    destpath=${outputpath}${thisdir}"/"

    echo -e "\n\n"
    echo "##### handling  ${file} #####################################################"
    
    if [ -f ${source_path2}${bname}  -a -f  ${destpath}${bname} ]; then
    echo "diff ${source_path2}${bname} ${destpath}${bname}"
    result=`diff ${source_path2}${bname} ${destpath}${bname} | wc -l`
    echo "result is ${result}"
    if [ ${result} -gt 0 ]; then
        echo ${file} >> diff.txt
    fi    
    fi
    
    if [ ! -e ${source_path2}${bname} ]; then
    echo ${source_path2}${bname} >>notInLeft.txt
    fi
    
    if [ ! -e ${destpath}${bname} ]; then
    echo ${destpath}${bname} >>notIndRight.txt
    fi
        
    
    
    echo "##### done!!!!  ${file} #####################################################"
done

2.1 找出文件区别打印出来

#!/bin/sh
if [ $# -lt 2 ]; then
    echo "Usage: ${0} fileList source_path other_path"
    exit 9
fi

fileList=$1
source_path=$2
outputpath=$3
result=0

echo ${source_path}

for file in `cat ${fileList}`
do
    thisfile=`echo $file|cut -d@ -f1`
    bname=`basename $thisfile`
    thisdir=`dirname $thisfile`
    source_path2=${source_path}${thisdir}"/"
    destpath=${outputpath}${thisdir}"/"

    echo -e "\n\n"
    echo "##### handling  ${file} #####################################################"

    echo "diff ${source_path2}${bname} ${destpath}${bname}"
    #result=`diff ${source_path2}${bname} ${destpath}${bname} | wc -l`
    echo "-----------------------------------------------------">>diffcontent
    echo -e "${source_path2}${bname} --> \n${destpath}${bname}" >>diffcontent
    echo "-----------------------------------------------------">>diffcontent

    diff ${source_path2}${bname} ${destpath}${bname} >>diffcontent
    result=0    
    echo "result is ${result}"
    if [ ${result} -gt 0 ]; then
        echo ${file} >> diff.txt
    fi
    echo "##### done!!!!  ${file} #####################################################"
done


3.根据列表提交SVN

#!/bin/sh
if [ $# -lt 4 ]; then
    echo "Usage: ${0} fileList svntagpath inputpath commit_comment"
    exit 9
fi

fun_svn_tag(){
        f1_c=`svn info $1 | grep "URL" | awk -F " " '{print $2,$NF}' | grep $2 | wc -l`
        return ${f1_c}
}

fileList=$1
svntag=$2
inputpath=$3
comment=$4

#run_flag="n"

if [ ${inputpath}"x" == ".x" ]; then
    echo "the inputpath cannot be "."!!!! exit(1)"
    exit 1;
fi

echo ${svntag}
tagname=`echo ${svntag} | awk -F "/" '{printf $NF}'`

for file in `cat ${fileList}`
do
    thisfile=`echo $file|cut -d@ -f1`
    bname=`basename $thisfile`
    thisdir=`dirname $thisfile`
    svnpath="."${thisdir}
    destpath=${inputpath}"/"${thisdir}

    echo -e "\n\n"
    echo "##### handling  ${file} #####################################################"
    echo "##### will copy from to ${destpath}/${bname}"

    echo "checking  "${destpath}"/"${bname}
    if [ ! -f ${destpath}"/"${bname} ]; then
        echo "the file "${destpath}"/"${bname}" is not exitsed !!!!, this file will be ignore"
        echo "file "${file}" is not exitsed !!!!!" >> error.log
        continue
    fi

    echo "checking  "${svnpath}"/"${bname}
    if [ ! -f ${svnpath}"/"${bname} ]; then
        echo "file not exits,  it will run svn checkout now !!!!"
        echo "svn co ${svntag}${thisdir} ${svnpath}"
        svn co ${svntag}${thisdir} ${svnpath}
    else
        #judge whether path is for the correct svn path
        echo "the path is already exited"
        fun_svn_tag ${svnpath} ${tagname}
        if_flag=$?
        if [ ${if_flag} -lt 1 ]; then
            echo "the path is not for this tag "${tagname}", it will be remove and checkout again!!"
            svnpathhead=`echo ${svnpath} | awk -F "/" '{print $2}'`
            echo "rm -rf ${svnpathhead}"
            rm -rf ${svnpathhead}

            #chekout out
            echo "svn co ${svntag}${thisdir} ${svnpath}"
            svn co ${svntag}${thisdir} ${svnpath}
        fi
    fi

    if [ ! -f ${svnpath}"/"${bname} ]; then
        echo "file is not existed at svn ! it will be execute svn add"
        echo "cp ${destpath}"/"${bname} ${svnpath}"/"${bname}"
        cp ${destpath}"/"${bname} ${svnpath}"/"${bname}

        echo "svn add ${svnpath}"/"${bname}"
        echo ${file} >> addlist.txt
        svn add ${svnpath}"/"${bname}
        if [ $? != 0 ]; then
            echo "file "${file}" is fail !!!!!" >> error.log
        fi
    else
        echo "the file is existed in svn alreary, it will be performed svn update"
        echo "svn update "${svnpath}"/"${bname}
        svn update ${svnpath}"/"${bname}

        echo "cp ${destpath}"/"${bname} ${svnpath}"/"${bname}"
        cp ${destpath}"/"${bname} ${svnpath}"/"${bname}
    fi

    echo "svn commit -m "${comment}" "${svnpath}"/"${bname}
    #printf "execute above command? (y/n):"
    #read ${run_flag}
    #
    #if [ ! ${runf_flag} == "y" ]; then
    #    continue    
    #fi

    svn commit -m ${comment} ${svnpath}"/"${bname}

    if [ $? != 0 ]; then
        echo "file "${file}" is fail !!!!!" >> error.log
    fi

    echo ${file} >> committed.txt
    echo "##### done!!!!  ${file} #####################################################"
done




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值