Monday, May 24, 2010
How to: Setup new Subversion Repository using a batch file
For those who use Subversion source control know that setting up a new repository can be tedious specially when you have to do it couple times a week or month.
I found myself doing it quite often and realized that I should automate this somehow, so here’s how I did it using simple a batch file.
To be able to have a custom name of the repository I wanted the batch file to prompt me in the first step,here’s how you do it
With the echo off here’s how the command prompt looks like.
When you type the name of the repo and hit Enter, subversion sets up some folders and files that it needs to operate.
In the conf folder it stores users credentials and permissions to check into this repository. You dont want to create them everyday specially for a small team, in my case I had to copy them from another repository that I have previously configured, so in the batch file I did this
%name% is the variable that holds the name of my repository.
Similarly in the hooks folder subversion stores different automated actions like pre-commit, post-commit, pre-lock and so on, in my case I wanted a demo server to update itself after every check-in to its repository, so in this case I could use post-commit hook that had this command.
Following line creates the hook with the svn update command.
Then I wanted to setup my demo_server, I had to create the folder with the name of my repository along with branches, tags and trunk folders. Here’s the complete snippet or you can view it here create_svn_repository.bat
Hope it helps someone out there, let me know in the comments.