SVN usage

Usage of version control should be mandatory at all times on projects with longevity of more than 2-3 weeks, whether you are working alone or in group. You should familiarize yourself with it. I used bazaar which is command line. Now I use TortoiseSVN which is very graphical and easy to use. But it has some quirks I want to get out of the way. You may think it’s lame, but it really does help you along if you do it right from the start.

1. Use trunk, branches and tags folders

In trunk: your development version on which you’re working.
In tags: your stable revisions, important (software) versions.
In branches:  when you want to make big changes or try something out without losing your stable development version so far. Switch “branches” between the trunk and branches folder to choose where you want to work on. Eventually, you should want to merge your changes back into the trunk once everything became stable. If a branch goes to lead a different life, it is called a “fork”. They share the same base, but became something different.

Learn to use switch, branch/tag!

2. Backup/Restore. Moving between svn servers.

Note: You’ll never create backups before it’s too late. Just do it!
Not long ago, I used assembla, a free svn service. However, having my own server and to make sure my data is secure, I wanted to move it from assembla to my server. Of course without losing file versions as I would with a regular svn export.

I set up visualSVN on the server. I exported an SVN dump file from assembla. Mind the few differences:

– Full svn with version control for server: this contains folders like “conf”, “db”, “hooks”, “locks”, …
This is strictly server side and should not be polluted by your files. Keep out!
– SVN checkout or repository: Your main directory and the result of a checkout of the svn server. This gives you an entire repository with all your files, including “.svn” folders with version control information.
– Exported repository: The result of an export of your repository. This contains all your files without the version control info. Smaller in size, but limited, so hold onto your directory with svn info.

Now, how do I get the dump from my svn host (assembla in my case) up on my own server? The dump is a .gz or .zip file. Unzip it somewhere easy to reach on your hard drive.
Go to VisualSVN server, start its command prompt and navigate to your repository folder on the server in the command line (with “cd” usually). Then enter

“svnadmin create foldername“.
“svnadmin load foldername < fullPathToYourUnzippedDumpFile

There. Now my revisions data is saved on my server. But my SVN checkout or ‘repository’ is still pointing to my online host (assembla). Simple, just create a new folder somewhere and perform a new SVN checkout from your server URL.

Maybe not that easy, but now your setup is done and you can enjoy the wonders of SVN again. Plus, now that you have control, you can explore additional useful svn features. I advise you to use TortoiseSVN. AnkhSVN is also quite useful for svn duties straight from Visual Studio. This will also help me remember if I ever need to relocate my svn server without losing my version control data.

This entry was posted in Software usage. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *