Pages

Tuesday, May 18, 2010

Forget to create trunk folder in SVN

Another one about SVN. Since i'm a bit hurry when adding my project to my SVN repositories. I forgot to create the common directories (trunk, branch and tags). After my project is stable i decided to move the code to the proper directories before tagging it.

After quick i found a simple and effective way. Since I'm working on windows, i made a simple batch script for it. Beware it tested lightly, and I didn't tune it to be a generic script.

@echo off
set repo=http://localhost/svn/myProject
echo "Repository location " %repo%

echo "Creating SVNTemp directory"
del SVNTemp
mkdir SVNTemp

echo "Checking out source from repo"
svn checkout %repo% SVNTemp

echo "Creating trunk in repo"
svn mkdir %repo%/trunk -m "creating trunk"

cd SVNTemp
FOR /F %%a IN ('dir /b *') do (
echo "Moving %%a to trunk"
C:\Progra~1\Subversion\bin\svn.exe mv %%a trunk
)
svn commit -m "organizing to trunk"
cd ..
@echo on

No comments: