svn export diff

Usage

svn-rev-diff-export.sh -u <path> -f revFROM -t revTO -o <path>

Options

-f, --rev-from revFROM
                    First revision number to compare.
-t, --rev-to revTO  Second revision number to compare.
-u, --url <path>    URL/path to repository.
-o, --output-dir <path>
                    The path to directory where the export will be placed.
                    Default: .

Requirements

svn and awk have to be available in current $PATH

svn-rev-diff-export.sh

# Exit on errors
set -e

# Initial variable definitions
OUTPUT_DIR="."

# Parse commandline options first
while :
do
    case "$1" in
        -f | --rev-from)
            if [ -z "$2" -o "$2" -le 0 ]; then echo "Error: --rev-from parameter not specified or invalid" >&2; exit 1; fi
            REV_FROM=$2
            shift 2
            ;;
        -o | --output-dir)
            if [ -z "$2" ]; then echo "Error: Output directory not specified" >&2; exit 1; fi
            OUTPUT_DIR=$2
            shift 2
            ;;
        -t | --rev-to)
            if [ -z "$2" -o "$2" -le 0 ]; then echo "Error: --rev-to parameter not specified or invalid" >&2; exit 1; fi
            REV_TO=$2
            shift 2
            ;;
        -u | --url)
            if [ -z "$2" ]; then echo "Error: SVN Repository URL/path not specified" >&2; exit 1; fi
            REPO_PATH=$2
            shift 2
            ;;
#        --) # End of all options
#            shift
#            break;
        -*)
            echo "Error: Unknown option: $1" >&2
            exit 1
            ;;
        *)  # No more options
            break
            ;;
    esac
done

# Checking if other required parameters are present and valid
if [ ! -d "$OUTPUT_DIR" ]; then echo "Error: Specified output is not a directory" >&2; exit 1; fi
if [ ! -w "$OUTPUT_DIR" ]; then echo "Error: Output directory is not writable" >&2; exit 1; fi

last_char=${OUTPUT_DIR:${#OUTPUT_DIR}-1:1}
if [[ $last_char != '/' ]]; then
    OUTPUT_DIR=${OUTPUT_DIR}"/";
fi

for i in $(svn diff --summarize -r ${REV_FROM}:${REV_TO} $REPO_PATH | awk '{ print $2 }');
do
    f=${OUTPUT_DIR}$(echo ${i#$REPO_PATH});
    mkdir -p $(dirname $f);
    svn export $i $f || echo "File $i is not found, skipped";
done
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 每日一省 导师班第二天(洛阳) 上午一位妈妈分享他的孩子上高中了不上学了。院长根据她诉说孩子的历程动用了...
    王兰芳阅读 126评论 0 1
  • https://card.weibo.com/article/m/show/id/2309404773709935...
    HT_c114阅读 47评论 0 0
  • 2022-05-27
    irenb阅读 108评论 0 0
  • 阿布老师讲的注意力的重要性,要有意识的去训练,否则注意力就涣散了,就真的差不多了。 感觉自己对注意力这个概念真的很...
    bacf95864465阅读 220评论 0 0
  • 《跃马扬鞭梦白马》 引诗一: 位面之子刘秀帝, 一骑绝尘白马先。 赤光伴生稼禾秀, 阔口美髯体壮健。 云台二十八将...
    经典一笑阅读 113评论 0 0