|   Register
Monday, December 01, 2008   
You are here :     Blog
SubVersion is my new friend!
Location: BlogsKing Wilder's Blog    
Posted by: kwdnnsuper 9/7/2007

SubVersion is not new, it's evidently been around for a few years, but it's new to me and it's great.  It has solved my common source code problems with, not the greatest of ease, but it did solve them.

What is SubVersion?  To put it plainly, it's a source control application.  What makes it great, is that it's completely FREE!  What makes it fantastic, is that you don't actually lock the source code from someone else if it's checked out.  It knows how to update even the smallest part of your application and keep track of it for others.

The reason it's great is that it works off of a server, either a built-in SVN server or Apache.  This makes it easily accessible from any computer on the network.  If you want to learn more about SubVersion, go to their website.

For Windows users like me, there is an indispensible tool built for SubVersion called TortoiseSVN.  TortoiseSVN is an easy to use Windows source control software add-on to SubVersion.  In essense it's a nice GUI tool for SubVersion.  Once installed it plugs itself into Windows Explorer and you can use it when you right-click on a folder.  All the commands you would have to use SubVersion are built into TortoiseSVN.

How do I use it?

Well first, you need to figure out the best way to use it for your network.  We'll assume you have one central server where you can install SubVersion.  SubVersion doesn't have to be the only application running on this server, but it's used because this is a server that you are making accessible for your developers.

So you download and install SubVersion on this server.  There are many places where you can either download the zip file, source code or some other binary source, but I found that the download module from Collab.net for Windows, is an installer that can install the Apache server also for you.  The other downloads, you have to install and configure Apache or SVN server to make it work.  You can get it here.

A word about Apache on Windows...

I was hesitant at first about installing Apache server on my Windows Server 2003 box that was running IIS 6.0.  But then I found out that as long as you change the port to something other than your default 80, you can run both without interference.  I have it running on my 2003 development box and all my IIS sites are working fine.

So follow the instructions and install the SubVersion server with Apache and then install TortoiseSVN.  Just to be clear, you install SubVersion server on one machine, and then install TortoiseSVN on each machine you will use as the client.  In other words, TortoiseSVN will be installed on each machine that you might want to run the source code on for testing.

An aside...  there is a version of a SubVersion controller like TortoiseSVN, that plugs into Visual Studio it's called AnkhSVN.  I prefer TortoiseSVN because I can use it for my straight HTML projects.

So, how do I use it?

Ok, sorry, I got side tracked... once you have both SubVersion server and TortoiseSVN installed on your machines, this is the one way of using it:

  1. Create a repository on the server, example MyNewProject folder, then right-click the folder and select "Create Repository here"
  2. Initialize the repository by importing something, even just a single blank text file
  3. Checkout the project to a new blank folder
  4. Work on the project and save your changes
  5. Commit your work back to the repository

That's essentially it.  It took me a little while to get my mind wrapped around how this works since I came from using Visual Source Safe where you just checked in your project, and checked it out.  Easy.  Well this is easy also, but you just need to alter your thinking.  Since SubVersion doesn't lock your project from being worked on, anyone can work on the same project and then Merge their work.  SubVersion takes care of that for you.

What if I already have a project created before I installed Subversion?

The biggest thing I had to understand, was that if I had already had a project created, I could create a new repository for it in SubVersion, then I would Import it into the repository.  At this point I don't have a checked out version of the project to work on that I can maintain with SubVersion.  What I need to do is, rename the existing folder for your project to something else.  Let's say you have a project called TimeTracker that was already in progress when you installed SubVersion.  You have just imported into your SubVersion repository.  Now renamed the TimeTracker folder to TimeTracker_old or something like that, and then create a new blank folder called TimeTracker.

Now right-click on that new folder and select the Checkout item and point to your servers repository, with a URL like http://10.4.4.2/svn/TimeTracker and make sure the folder it's checking out to, is the new empty TimeTracker folder.  Click the OK button and the project from SubVersion will be checked out to your folder and it will be decorated with little green checks.  That tells you that the checkout worked.

Now you can just work on that new project as you always have.  When you are finished with an iteration, Commit your changes back to the repository.  SubVersion keeps track of the revisions for you.  If someone else worked on the project on a different machine, you can update your project by right-clicking on the folder and selecting Update.

Summary...

SubVersion has allowed me to easily work on several different machine all using the same source code.  So if I end up working on a development server to debug a problem that I built on my XP laptop, I don't have to worry about modifying the code and trying to keep it in synch with my XP code.  I just Check it out on the server and work on it there, and then Commit my changes.

I hope this has given you a little insight into the source control application SubVersion.

Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel 
King's Blog
King's Blog
King's Blog

Copyright 2007 by King Wilder   |  Privacy Statement  |  Terms Of Use