Updating multiple SVN working copies at once.

This is not really audio related, but maybe someone is interested anyway …

We use Subversion (SVN) for several different things — software, papers, scripts — and one of the most common tasks is to update working copies all over the place. This can be quite annoying if you are working on many SVN repositories.

To make this repetitive task a little easier, the following scripts can be used.

Therefore, create a new directory and put all your working copies in subdirectories and use one of the following scripts to do the rest of the work.

Windows

I suppose you have TortoiseSVN installed — if not, install it.

Put the following in a file with the extension .bat, place it in the directory with your working copies and double-click on it.

@echo off
FOR /D %%A IN (*) DO START TortoiseProc.exe /command:update /path:%%A /closeonend:0

(The basic idea is stolen from here.)

Linux/Unix/…

Put the following code in in a file, make it executable and put it in the directory with the working copies (or somewhere in your path, e.g. in $HOME/bin/). Then start the script.

#!/bin/bash

# Shell script that runs "svn update" in each subdirectory.
# If arguments are given, they are used instead of "update".
# The script also works if a directory name contains spaces.

COMMAND=svn
# if no options are specified on the command line, this is used:
OPTIONS=update

LOGFILE=error.log

if [ $# -gt 0 ]
then
  OPTIONS="$@"
fi

for DIR in */
do
  echo "============> entering "$DIR""
  (cd "$DIR" && $COMMAND $OPTIONS) 2> >(tee -a $LOGFILE >&2)
  echo "============> leaving  "$DIR""
  echo
done

# if error-log is empty, remove it
if [ $(wc -l < $LOGFILE) -eq 0 ]
then
  rm -f $LOGFILE
fi
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

One Response to Updating multiple SVN working copies at once.

  1. Jay says:

    Great Script. Was exactly what I was looking for.

    Jay

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.