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
网友评论