I wrote a bash script for taking diffs between two repositories.
If you would like to learn more about Bash script. I recommend read following books.
#!/bin/bash SVN_USERNAME=dukesoftware SVN_PASSWORD=some_password SVN_COMMON_COMMAND="svn --username $SVN_USERNAME --password $SVN_PASSWORD --non-interactive --ignore-externals --quiet" SVN_COMMON_UPDATE_COMMAND="$SVN_COMMON_COMMAND update --set-depth infinity" SVN_COMMON_CHECKOUT_COMMAND="$SVN_COMMON_COMMAND co --depth immediates" SVN_BASE_URL=http://svn.repository.dummy.com/projects/ # comparison svn urls SVN_URL1=$SVN_BASE_URL/url1 SVN_URL2=$SVN_BASE_URL/url2 DIR1=target1 DIR2=target2 OUTPUT_DIR=diff_out EXCLUDE_FILES=(".svn" "jquery-*.min.js") # To minimize number of checkout files, set below constants CHECKOUT_DIRS=("dir1" "dir2" "lib") DIFF_TARGETS=("dir1/sub1" "dir1/sub2" "dir2" "lib") # function definitions build_base_diff_command(){ DIFF_BASE_COMMAND="diff -E -B -b -u -r" for exclude_file in "${EXCLUDE_FILES[@]}" do DIFF_BASE_COMMAND+=" -x $exclude_file" done } update_subdirs(){ for dir in "${CHECKOUT_DIRS[@]}" do echo update "$SVN_URL1/$dir" $SVN_COMMON_UPDATE_COMMAND $DIR1/$dir echo update "$SVN_URL2/$dir" $SVN_COMMON_UPDATE_COMMAND $DIR2/$dir echo "" done } generate_diff(){ for dir in "${DIFF_TARGETS[@]}" do echo "generating diff for $dir ...." #DIFF_FILE="$OUTPUT_DIR/diff_$SUBDIR.`eval date +%Y%m%d.%H%M%S`.diff" DIFF_FILENAME_BASE=${dir////_} DIFF_FILE="$OUTPUT_DIR/diff_$DIFF_FILENAME_BASE.diff" $DIFF_BASE_COMMAND $DIR1/$dir $DIR2/$dir > $DIFF_FILE echo "diff done - $DIFF_FILE" echo "" done } clean_output_dir(){ rm -r -f $OUTPUT_DIR } setup_output_dir(){ rm -r -f $OUTPUT_DIR mkdir -p $OUTPUT_DIR } checkout_base(){ $SVN_COMMON_CHECKOUT_COMMAND $SVN_URL1 $DIR1 $SVN_COMMON_CHECKOUT_COMMAND $SVN_URL2 $DIR2 } checkout_base_if_not_preset(){ if [ ! -d $DIR1 ] then $SVN_COMMON_CHECKOUT_COMMAND $SVN_URL1 $DIR1 fi if [ ! -d $DIR2 ] then $SVN_COMMON_CHECKOUT_COMMAND $SVN_URL2 $DIR2 fi } cleanup_checkout_dirs(){ echo "Cleaning up checkout directories..." rm -r -f $DIR1 rm -r -f $DIR2 } generate_diff_count(){ echo "Calculating diff number of lines...." echo "YVALUE=`diff -r -U 0 $DIR1 $DIR2 | grep ^@ | wc -l`" > $OUTPUT_DIR/diff_lines.txt } # capture for exit status for each command execution set -e set -o pipefail # entry point build_base_diff_command case "$1" in clean_diff) cleanup_checkout_dirs checkout_base update_subdirs setup_output_dir generate_diff generate_diff_count ;; clean) cleanup_checkout_dirs clean_output_dir ;; diff_count) generate_diff_count ;; *) checkout_base_if_not_preset update_subdirs setup_output_dir generate_diff generate_diff_count ;; esac exit $?
If you would like to learn more about Bash script. I recommend read following books.
コメント