Last time we spoke I left you with two repositories and waiting to put data into them.

So let’s get on with that, then.

In a temporary directory create your ferrari and bugatti folders here, and in them create the standard Trunk, Tags, and Branches (TTB).

Now switch into the two directories and run svn import on each:

D:\temp\bugatti>svn import .\ svn://localhost/bugatti -m "Commiting the initial TTB layout to repository"
Authentication realm: <svn://localhost:3690> 4f93af25-16dc-3d41-b82e-acee2e868d11
Username: graham.reeds
Password for 'graham.reeds': ********
Adding         trunk
Adding         branches
Adding         tags

Committed revision 1.

You can delete these temporary folders since they are no longer required.

Let’s start doing something useful with them.

In your directory where you normally do your programming, create a directory to hold the projects we are going to write. Due to a lack of imagination on my part, I use a directory called projects, also on drive D, to hold my projects.

So switch there and let’s get to work creating the directories.

The first will be project ferrari, so create a project folder named ‘ferrari’. In that directory issue the check-out command:

D:\projects\ferrari>svn co svn://localhost/ferrari/trunk ./
Checked out revision 1.

If you look at the folder you will see that a hidden folder called .svn has appeared. Open up Visual Studio (or similar if you use another IDE) and create a Win32 project called ferrari. For this I will accept all the defaults so the 20 or so files will demonstrate my purpose perfectly – I also prefer to configure my directory structure to something more convenient but that can be another blog topic.

So we now run ‘svn add’ and are greeted by the following sight:

D:\projects\ferrari>svn add ./*.*
svn: Skipping argument: '.svn' ends in a reserved name
A         ferrari
A         ferrari\ChildFrm.cpp
A         ferrari\ChildFrm.h
A         ferrari\ferrari.cpp
A         ferrari\ferrari.h
A         ferrari\ferrari.rc
A         ferrari\ferrari.vcproj
A         ferrari\ferrari.vcproj.DIGITAL-UTOPIA.graham.reeds.user
A         ferrari\FerrariDoc.cpp
A         ferrari\FerrariDoc.h
A         ferrari\FerrariView.cpp
A         ferrari\FerrariView.h
A         ferrari\MainFrm.cpp
A         ferrari\MainFrm.h
A         ferrari\ReadMe.txt
A         ferrari\res
A  (bin)  ferrari\res\ferrari.ico
A         ferrari\res\ferrari.rc2
A  (bin)  ferrari\res\ferrariDoc.ico
A  (bin)  ferrari\res\Toolbar.bmp
A         ferrari\Resource.h
A         ferrari\stdafx.cpp
A         ferrari\stdafx.h
A  (bin)  ferrari.ncb
A         ferrari.sln
A  (bin)  ferrari.suo

The add command means they are now being watched by subversion (as exposed by the hidden .svn folder in the ferrari subdirectory). However they are not in the repository just yet. We need to commit them. This is fairly simple.

D:\projects\ferrari>svn ci ./ -m "Initial commit of the default project files"
Adding         ferrari
Adding         ferrari\ChildFrm.cpp
Adding         ferrari\ChildFrm.h
Adding         ferrari\FerrariDoc.cpp
Adding         ferrari\FerrariDoc.h
Adding         ferrari\FerrariView.cpp
Adding         ferrari\FerrariView.h
Adding         ferrari\MainFrm.cpp
Adding         ferrari\MainFrm.h
Adding         ferrari\ReadMe.txt
Adding         ferrari\Resource.h
Adding         ferrari\ferrari.cpp
Adding         ferrari\ferrari.h
Adding         ferrari\ferrari.rc
Adding         ferrari\ferrari.vcproj
Adding         ferrari\ferrari.vcproj.DIGITAL-UTOPIA.graham.reeds.user
Adding         ferrari\res
Adding  (bin)  ferrari\res\Toolbar.bmp
Adding  (bin)  ferrari\res\ferrari.ico
Adding         ferrari\res\ferrari.rc2
Adding  (bin)  ferrari\res\ferrariDoc.ico
Adding         ferrari\stdafx.cpp
Adding         ferrari\stdafx.h
Adding  (bin)  ferrari.ncb
Adding         ferrari.sln
Adding  (bin)  ferrari.suo
Transmitting file data ........................
Committed revision 2.

This can be confirmed by the ls command:

D:\projects\ferrari>svn ls svn://localhost/ferrari/trunk -R

We can now proceed with the project right? Well you could but you would be missing probably the most important thing about source control. Imagine you were working on an important project, you have pushed the latest release out the door and now are working on some very exciting new technologies extending it when your manager walks over and tells you that the important client has a problem in the FooBar when accessed by the Baz. He also informs you he has sent you an example set of data that demonstrates this flaw attached to an email and expects that the fix will be prompt and rigorously tested. Sure enough, once stepped through in a debugger you can see it and the fix is fairly trivial and has zero impact you can discern, but you are partway through an enhancement – there are partially written dialogs and functionality is greatly missing and won’t be ready for weeks. What can you do?

Well that’s where branching comes in handy. A rule of mine is that trunk should always be in a compilable state – no exceptions. So if that is the rule, how can we implement it? Well with branching. A branch is a fork of the code. With that code you can make as many adjustments as you like, and if the above situation occurs you can simply make another branch, work on that and then when the adjustments/modifications/fixes are made you can merge them back in with the main trunk. With due care branching can improve efficiency amongst a team, but it’s not with out drawbacks. That will be the topic of my next blog entry.

That’s about it – remember you can do the same stuff for the bugatti project also.