Thursday, August 13, 2009

recursive svn cleanup!

Did you ever experienced a couple of random directories in your working copy getting locked by svn for no particular reason? And your favorite SVN interface told you 'Directory xxx is locked use svn cleanup'? or for some other reason do you need to run a recursive clean up command?

anywho...
It happened to me more than enough to write a very simple shell script.


#!/bin/bash
mysvnclean() {
if [ -d $1 ]; then
for tmpDescendDir in $1/*
do
if [ -d $tmpDescendDir ] && [ $tmpDescendDir != ".svn" ]; then
svnLookupDir="${tmpDescendDir}/.svn"
if [ -d $svnLookupDir ]; then
echo "$tmpDescendDir"
svn cleanup $tmpDescendDir
mysvnclean $tmpDescendDir
fi
fi
done
fi
}
mysvnclean $1


save this script with "anyname.sh" and run in like
sh anyname.sh /top/path/to/cleanup

No comments: