CVS Saves My Life Once Again
Listen to this article
Some time ago I trashed my linux machine by running rm -rf on a logical mount that, for reasons too mundane to discuss, was pointed at the root partition. Yes yes, snigger snigger hehe but tell me you've never done something similar :P. Anyway, a day or three later, I had resurrected my machine and restored all my files from those non-existant backups that we all vow to make...one day.
I deploy stuff to my various websites using ant scripts. Each time I deploy a new version of a product or project or even just make a change to some static HTML, it's automatically shipped using JSCH then some shell commands are rune using SSH to move stuff around/configure things as necessary.
Up until about an hour ago, I had been using a semi-colon (;) as the command delimeter with no issues at all. There is problem with this that I had never considered - If any of the commands fails, the shell keeps on executing the remaining commands! Now in my case, one of those commands changes directories and is followed immedately by, you guessed it, rm -rf *. Not a problem if everything goes to plan but I had just recently renamed said directory! Needless to say, it wasn't pretty.
It then occurred to me that what I should have been using were double-ampersands (&&) which terminate execution at the first failure. Even better would be to simply rename (move) the existing directory and create a new one; My newly adopted strategy.
Thankfully, all my projects and web sites are in CVS so restoring them is never a problem which got me thinking about all the bits of code I've seen commented out or the unused classes left lying around because, like all those off-cuts of building material you're keeping in the shed, "who knows when I might need that."
More often than not CVS is used purely as a central repository that all developers can access but it can and should be more than that. Having everything in CVS allows greater fluidity in development. It allows developers to try something out and if it ends up completely borked, well, we can always just roll back. James even suggested (now that he's a CVS guru along with Jon :P) using CVS branching to do some speculative changes without disturbing the guys on the trunk whilst still allowing us to check-in the code. This is certainly something I would have been extremely reluctant to do even 3 months ago but having seen it work out (so far) for one of the projects on which we depend, I'm rather more inclined to give it a go.
As developers, we need to feel comfortable with and trust that all of this is possible. I doubt that many people I've met actually understand all the subtleties and features of CVS, myself included. One thing I know for sure is that resurrecting dead files in CVS isn't nearly as simple as it sounds. I'm hoping Subversion will address this but right now, something tells me that after everything I've just said, using beta-software for SCM on my critical projects is, perhaps, not the smartest thing one could do.
Comments
I suspect most people use CVS and version control systems in general as a shared file system. What they're missing is that it's also a very sophisticated undo. And then there's the multiple lines possible with branching.
One of my pet peeves is the phrase "code freeze" which I immediately suspect indicates the person doesn't understand how version control systems works.
Posted by: Jason Yip | November 7, 2004 05:36 PM
Exactly. Shared file system are indeed the words I was looking for.
Posted by: Simon Harris | November 7, 2004 05:56 PM
Since when is version 1.1.1 of something beta? I think you should have another look at Subversion.
Posted by: Michael Strasser | November 7, 2004 07:39 PM
Once again, my ignorance knows no bounds :-)
Believe me, nothing would make me happier than to start using. There are so many features to which I look forward. Maybe BETA was a poor choice of words. I guess I'm waiting until some people I trust start telling me how wonderful and stable it is before putting on my critical project path.
It may be time to have another look.
Posted by: Simon Harris | November 7, 2004 07:47 PM