Friday, June 26, 2009

Version control: Autopia vs. off-roading

When I was a kid, it was cool to go to Disneyland and ride the Autopia ride. For those of you unfamiliar with it, you get to "drive" a car along a track. As I recall, you get a gas pedal, and the steering worked for about plus-or-minus a foot off the center-line of the track. It is a far cry from driving a real go-cart let alone a real car on the highway or going off-roading (not that I've ever intentionally been off-roading.) Comparing traditional centralized version control systems to distributed version control systems is a bit like autopia vs. off-roading.

With a centralized version control system (VCS), your options are limited, and to a certain extent that can be a good thing. A critical difference between Autopia and a centralized VCS, is that the VCS actually goes somewhere - your code line continues to move forward and doesn't loop back to the starting point.

A distributed VCS (DVCS) can follow the exact same path that a cetralized VCS provides/requires - just like you could drive a 4x4 along the Autopia track. With a DVCS tool like Mercurial, you can implement policies that end up following the same trajectory as you would with Subversion. You have one "master" repository; everyone checks out from it; everyone commits directly to the central repo; the only branching is officially sanctioned, and it occurs in master repo. And that's fine for a lot of applications. Also, some organizations want to operate on the straight and narrow, which is fine if it works for them.

As I mentioned before, I think Mercurial is very simple to use on that path. But, the blessing or curse or fun or power of a DVCS is that you need not follow that track. You can go off the track. Doing so might be the fastest way to get where you're going. Or, you might end up in the weeds. And, you can drive back onto the main road. Developers can head off in some strange direction in their private repo, share their changes with other repos, bring in changes from other repos, abandon their work, or merge it all back into the designated "main" repo. All the while, they have a real VCS tracking their work and saving it - not just random hacking in a random directory.

If Autopia is where you want to be, more power to you. I wouldn't recommend using a DVCS in that environment. Although I don't go seriously "off-road" in my development, I like to have the option to get a little mud on the tires. And even if I'm "driving on the track" and using Mercurial like a centralized VCS, I like to clone a tree onto my laptop to operate disconnected for an extended period, which is something that's not generally possible with traditional VCSs.

My most "extreme" use of Mercurial to-date has been to mirror a P4 repository that I only have intermittent access to. Hg lets me do all my work without having to get the admin to let me onto the P4 repo from by dyanamic IP address. Before that, I would work for weeks without checking in, which makes me nervous. Due to some ignorance and poor planning, I created a bit of a mess in my hg development repo, but I was able straighten it all out, build a series of mq patches, stage them on another repo, and push them back to the P4 tree.

No comments: