By Graham Asher, Cartography Ltd.
At my first job we used to make backups on floppy disks and put them into a box. The disks would be labelled “backup”, “backup 1”, “master backup”, “backup master”, and so on, except for the one disk used by my boss, which didn’t have a label. He explained that there was never any doubt about which one it was because it was the only disk without a label.
Another boss of mine used what you could call a stack algorithm. Everything that passed through his working life ended up in a stack on his desk, about three feet high, composed of letters, envelopes, magazines, disks, and scribbled notes. Every now and then he would make a backup and put it on the stack.
These systems must have worked because we released usable software from time to time. But they weren’t fun and they weren’t easy.
Skip forward twenty years and I am sitting at a desk looking at a little ‘P4′ icon on animated legs, walking and walking while I wait for something to happen. I am using Perforce, a proper source code control system.
Perforce stores all the code you use to build your project, in a repository (large collection of files with a history of all changes) on a remote server. You download copies of the files you need, and when you want to change a file you check it out, which means telling Perforce you are working on it so that it can warn other users you might also want to edit it. When you are happy with your changes, you check the file in, supplying some notes about the changes you made.
Using Perforce was wonderful, but that was at a large company, Symbian Ltd., which could afford a license for all of us three hundred developers, at a cost of several hundred US dollars per seat.
In 2000 I became a freelancer and I decided right from the start to use source control for all of my projects, private and paid-for. That included setting up a local repository for code that I also checked into clients’
repositories, so that I could keep track of what I did in my way, without necessarily being tied to their practices. I used Perforce, which is free for depots with up to two client specs, which are views of the data. Each user has to have at least one client spec, so you are restricted to two users, and in practice you’ll need two or more client specs yourself, so this free offer is of little use if you have multiple developers.
Some of my clients used CVS, which is completely free and has a Windows client. Unfortunately CVS is very hard to use (in fact I find it unusable without severe, painful effort) because it doesn’t have uniquely-numbered states like Perforce change-list numbers. The great thing about Perforce – in fact the one thing that is essential in a usable source control system – is that every check-in gets a single unique number called a CL or change-list number. CLs start at 1 and go up one by one for the lifetime of the source code repository.
The solution is Subversion. I promise you that Subversion will change your life. It is free, open source, has a wonderful Windows client called TortoiseSVN, and uses unique numbers, incremented one by one, just like Perforce, for every change. In fact, it goes further than Perforce and stores every state of the file system – that is, not just changes to files, but file moves and renames. You can give arbitrary attributes to files and it stores and tracks them too.
The TortoiseSVN Subversion client runs as a Windows Explorer extension.
(Perforce now has an explorer extension but it is nowhere near as good.) What that means is, it adds some menu items and extra sub-menus to the File menu in Windows explorer. To check a file out, do a diff, look at old versions, or whatever, you just open Windows explorer, click on the File menu, and choose a Subversion command. You can customise how the Subversion commands appear in the menu, but the standard arrangement is fine.
Subversion also overlays the Windows file icons with little sub-icons that tell you the Subversion state of the file – up to date, changed, added, etc.
The Subversion home page is http://subversion.tigris.org/. If you are using Microsoft Windows, I recommend going straight to the TortoiseSVN page
(http://tortoisesvn.tigris.org/) and downloading TortoiseSVN, which installs Subversion for you.
It’s possible, and in fact quite easy, to store all your data on your local computer or one on your local network. You can also set it up on your own server, for example using Apache. Or -and this is what I do, which is very convenient for small organisations with developers all over the place – you can pay a hosting service to store your Subversion repository. The nice thing about doing that is that you automatically have an offsite backup as well as a source code repository. The difficulty is the fact that you have to pay for it. I use CVSDude, run by the energetic and helpful Mark Bathie.
CVSDude offers a free plan for up to 2MB of data and a single user, but the major point of remote hosting is to allow more than one user, so that is less useful than it looks. It is incredibly good value for money, though:
the ‘Developer’ plan gives you 200MB of space and 4 accounts for 105 US dollars a year.
I see that I’ve written far too much and not written enough about why Subversion is so good. Let me just mention two features that make it better, for me, than Perforce or anything else I have used:
1. Unique release numbers. I can’t stress this too much. I can synch to any state of the source code using one number, and note that a certain release, at a certain date, represents release N. This helps me track bugs. When I make a check in of some code, my check-in note reads something like “Fixes ‘Case 540: draw overlapping icons in order of creation’.” Case 540 is the FogBugz case number. In FogBugz, my defect tracking system
(http://www.fogcreek.com/FogBugz/) I close the case with the note “Fixed by change 176.”
2. An excellent combined diff and merge utility. Often I make some ‘good’
changes, forget to check them in, then mess up the file with some ephemeral experimental changes. No problem. I just right-click on the file in Windows Explorer, select TortoiseSVN->diff, then I can click on the changes I don’t want and use the command ‘use other text block’ to selectively revert them without disturbing the ‘good’ changes.
It’s hard to put my finger on exactly why Subversion (by which I mean TortoiseSVN and Subversion together) is so much nicer to use than Perforce.
It’s a combination of reliability, good graphic design, ease of use and sheer naturalness.
Graham Asher runs Cartography Ltd, a micro-ISV with one product, CartoType (http://www.cartotype.com), a portable library for drawing beautiful maps and calculating routes on mobile devices and PCs. He can be reached at firstname.lastname@example.org.
By Graham Asher, Cartography Ltd.