Tuesday, August 5, 2014

Parallel SVN up for workspace with svn:externals

Yo, svn users!
Say we have a workspace with lots of svn projects. And workspace is related to the project via svn:externals property.


Here is a nice short script that saves a lot of time performing svn update in parallel:


#!/bin/bash
set -x
if [ -z "$1" ]
then
SVN_REV=""
else
SVN_REV="-r $1 "
fi

svn up --ignore-externals ${SVN_REV} .

svn pg svn:externals . | \
  grep -v "^$" | \
  sed -e "s/\^//g" | \
  awk '{ print "svn co https://my_repo.com"$1" "$2 }' | \
  sed -e 's/$/ \&/g' \
  > _svn_up_parallel

cat _svn_up_parallel
bash _svn_up_parallel
rm _svn_up_parallel


script description:

  grep -v "^$"  - removes empty strings from svn:externals
  sed -e "s/\^//g"  - removes ^ from lines
  awk '{ print "svn co https://my_repo.com"$1" "$2 }'  - converts record from 
           "/my_project1/trunk my_project1" to "https://my_repo.com/my_project1/trunk my_project1"

  sed -e 's/$/ \&/g' - inserts a " &" at the end of each line to send the command to background

No comments:

Post a Comment