Getting up to speed with SVN on Windows
I’ve been saying it for a couple of years now. “I’ve got to get all my projects under source control!” We all know it’s the right thing to do. The smart thing. But for some reason it never got done, or got partially done only to fall apart later because of the half measures taken. Well last night I finally decided to sit down and kick myself into doing it. Surprisingly, it was much easier than I feared.
I’ve had a WAMP stack on my laptop for quite some time, for all of my personal projects, and for work projects if I need to be offline from the office. My personal favorite is XAMPP, because of the ability to drop it on a USB stick if I need to and go.
I’ve also had SVN installed for quite some time. I use the package with the Apache 2.2 bindings located at Tigris.org (they also have an Apache 2.0 version available).
It was as simple as going into the file c:\xampp\apache\conf\httpd.conf and adding a couple of lines to get things up.
LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module "C:\Program Files\svn\bin\mod_dav_svn.so" <location /repos> DAV svn SVNParentPath C:\svn_repository </location>
Basically this loads the WEB_DAV module and the SVN extensions to that. Then it defines the location /repos to be the root of my subversion repositories. Using the SVNParentPath directive tells SVN to look for a directory in C:\svn_repository that matches the repository name you are trying to access.
Example:
I build a repository Foo at C:\svn_repository\foo. I access it by visiting http://localhost/repos/foo
Once this is up and running I installed http://tortoisesvn.tigris.org/. This makes it simple to create repositories and manage working directories by integrating the SVN functions with the windows explorer context menu.
Finally, I use Eclipse to do my development, so I installed Subclipse to add SVN integration to Eclipse.
Now it came to the most tedious portion. I had SVN installed, the server configured, and the management tools in place. Now its time to import some projects.
Going to the C:\svn_repository directory I create a new folder {project-name} for the project I am going to import. I right click on the folder and select the TortoiseSVN sub-menu and click on Create Repository Here. I select Native File System and click on OK. Congrats, your repository is waiting. You can confirm this by visiting http://localhost/repos/{project-name} . You should see revision 0 and an empty directory.
I use the recommended repository structure from the book Version Control with Subversion. I create a temporary directory and within it I create a directory named for the repository. Within that directory I create the tags, branches and trunk directories and copy the project files into the trunk directory. I back out to the temporary directory, and right-click on the project directory. From the context menu I select the TortoiseSVN sub menu and click on Import. You will be asked what repository you would like to import to. Enter http://localhost/repos/{project-name} . Where project-name is the folder name you created the repository above. Enter an initial comment to describe what you are doing, and maybe what the project is. Click on OK and sit back and watch as your project is imported.
Congratulations, you are now under revision control!