Saturday, April 18, 2009

Subversion 101

This post covers the fundamentals of subversion, the popular version control system. I'll show how to use subversion to version-control linux-2.6.29.1 kernel on your local server (I had to set this up for easy management of my kernel assignment). But before we begin, let's get familiar with some of the subversion terms.


You do a check-out when you download some project from the server to your local machine, this creates the working copy for your subsequent modification.


You do a check-in or commit when you upload your changes to the server.


Self explanatory, update updates your code with the latest changes from the server.


Doing an export will download the latest update from the server, but without subversion metadata, so you cannot upload the changes to the server from here. This mode is generally used to make the distribution tars.


import will bring the data imported under subversion's control system.


Now that we know the basic, let's do some command line stuff. I'm assuming you have subversion installed in your system by now. In Ubuntu you can easily do this by sudo apt-get install subversion svnadmin.


First step is to create the repository, typically its created in /var/svn/. So issue the command svnadmin create /var/svn.


subversion can be run under several protocols, like svn:// or http://. But right now we don't want to bother with that, we'll use simple file:// for local access.


First we need to create several folders in our repository. trunk is the folder where we'll put or main code. We'll use branches and tags when we think that we need to create several fork of the same project. So,



svn mkdir file:///var/svn/trunk
svn mkdir file:///var/svn/branches
svn mkdir file:///var/svn/tags


Now import your linux source code into svn,

svn import ~/src/linux-2.6.29 file:///var/svn/trunk/linux-2.6.29.1 --message "Importing linux kernel 2.6.29.1"


Go to the folder where you want to create the working copy.

svn checkout file:///var/svn/trunk/linux-2.6.29.1


Edit files as needed. Then check status by,

svn status


Update code from server

svn update


Commit your changes

svn commit --message "Added some feature"


Create a branch

svn cp file:///var/svn/trunk/linux-2.6.29.1 file://var/svn/branches/linux-2.6.29.1-vanilla -m "Creating a branch for the vanilla kernel"


If you don't like command line, use rapidsvn. It has a really nice GUI. Also popular IDE like Netbeans and Eclipse has build in subversion support.

I'll try to cover using subversion over http in my next post.

Back to Blogging

After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...