get updated files from svn repository

i was struggling to find little utility for export/get only changed file from my repository after some updates
to be send as “patches” or “updates” to current production environtment or to the client.

here is original nice bash commands for exporting updated files between 2 revision from svn repository
found from  interspire developer network
for i in $(svn diff --summarize -r 1403:1438 http://server/svn/project/trunk |
awk '{ print $2 }'); do p=$(echo $i | sed -e 's{http://server/svn/project/trunk/{{');
mkdir -p $(dirname $p); svn export $i $p; done

and i made bash script to to simplify this task

#!/bin/bash
EXPECTED_ARGS=2
E_BADARGS=65
#check at leat given 2 paremeters, url and revision number
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {repo_url} {rev1} [rev2]"
exit $E_BADARGS
fi
REPO=$1
# ask for svn username and password
echo -e "enter your svn username: \c"
read USER
echo -e "enter your svn password: \c"
read PASS
#get latest revision number if no third parameter given
if [ -n "$3" ]; then
REV=$2":"$3
else
REV=$2":"$(svn info --username $USER --password $PASS -r HEAD $REPO | grep Revision: | cut -c11-)
fi
echo "exporting update $REV from $REPO\n"
#do the job to export the updated files to update-$rev1-$rev2 directory
for i in $(svn diff --summarize --username $USER --password $PASS -r $REV $REPO |
awk '{ print $2 }'); do p=$(echo $i | sed -e 's{'$REPO'/{{');
p="update-"${REV/:/-}"/"$p
mkdir -p $(dirname $p); svn export --username $USER --password $PASS $i $p; done

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s