Last last Friday, I took some code home to work at over the weekend. When I came back to work on the following Monday, I couldn't commit the changes to the Subversion repository. Further investigation led me to discover that most of the tmp directories inside the hidden .svn folders were missing. It seems that the archive tool I used ignored empty directories. To fix this, I cooked up a quick script in groovy as shown below:
File currentDir = new File(".")
processDirectory(currentDir)
void processDirectory(File dir){
println "Processing "+dir.getAbsolutePath()
//check if .svn dir exists
String path = dir.getAbsolutePath()
File svnDir = new File(path+"/.svn")
if(svnDir.exists()){
if(svnDir.isDirectory()){
//check if tmp dir exists
File tmpDir = new File(svnDir.getAbsolutePath()+"/tmp")
if(tmpDir.exists()){
println "tmp folder already exists "+tmpDir.getAbsolutePath()
}else{
tmpDir.mkdir()
}
}else{
println ".svn is NOT a directory"
}
}else{
println "no .svn dir"
}
dir.listFiles().each{ file ->
println "Processing "+file.getAbsolutePath()
if(file.isDirectory()){
if(file.name == ".svn")
return
println "Processing "+file.getAbsolutePath()
processDirectory(file)
}
}
}
To use this fix, open a text editor and copy paste the code above into an empty file and save it as fixSvn.groovy to the folder of the workspace you want to fix
Make sure you have
groovy installed then do
groovy fixSvn.groovy
Did it work for you? You are welcome to post your comments/questions or better yet, link to this post, blog about it and tell all your friends who might find this post useful.