For some reason, repositories can be moved around. If you are using a working copy to develop a program or web-application or whatever, the move usually only implies a ‘check-out’ and you are set.
However, sometimes the repository is part of a production environment. To be precise, the production version is prepped in a special branch and then deployed using Subversion. Upgrading a website to a newer version only requires a ‘svn up’ and if you automate the database upgrades as well, web management becomes a breeze.
You might imagine that moving the repository in such an environment is less than desirable: each site or application which is part of that repository becomes un-upgradable and checking out everything by hand and setting it all up (plus the verification that every part is still functional) becomes a time consuming task.
However, the SVN information is all stored in plain text files. The following snippet switches the repository from http://svn.mydomain.com/svn
to svn://svn.someotherdomain.com
. This means you can quickly switch protocol, host names or even the location within a certain host. Simply copy-paste the code below into a file in the directory holding one or more projects for that repository, change the URLs (do not forget to escape by replacing ‘/’ with ‘\/’) and run the script.
#!/bin/bash DIRS=`find . -name ".svn"` for dir in ${DIRS} do echo "Processing $dir" FILES=`find $dir` for file in ${FILES} do if [ -f ${file} ]; then echo "Fixing '${file}'..." sed 's/http:\/\/svn.mydomain.com/svn:\/\/svn.someotherdomain.com/g' "${file}" > "${file}.tmp" mv "${file}.tmp" "${file}" fi done done