Archive for July, 2010

SVN Switch and Relocate Everything

July 22nd, 2010

We recently had a server DNS name change that affected our main SVN repository server, and required every checkout to be svn switch –relocate ‘ed.

In Eclipse I have every project checked out in ~/workspace/ so every directory with the matching server root would need to be switched. This shell script handled all the svn switch –relocate statements for me. Replace oldservername and newservername.

for dir in `ls -1 */.svn/entries | xargs grep -H -l oldservername | grep -E -o "^[^\/]+"`; do
svn switch --relocate `svn info $dir | grep ^Repository\ Root | cut -f 3 -d ' '` `svn info $dir | grep ^Repository\ Root | cut -f 3 -d ' ' | sed 's/oldservername/newservername/'` $dir
done

It may be best to make a backup of your project directories, especially if you have local uncommitted changes. This script works on bash-like command lines, such as Mac OS X.