Mercurial is Teh Awesome

My team at work recently switched from Subversion to Mercurial for revision control. That’s no small feat for a hardware design team (see: Averse to Change). It helps a little that we are mainly FPGA people (a lot “softer” than an ASIC), but there are still definitely hardware attitudes about change. Our software partners made the change a while ago, so they already had some process and infrastructure set up that made it easier for us, plus they could point out from real experience that it was an easy transition with many benefits. That helped a lot.

I took the lead on making the change for our team (is it true everywhere that on a digital design team, the verification engineers are the de-facto “tool guys” as well?). I studied up on how exactly mercurial works. I mean, I had the basic idea down since I’ve been toying with the fancy new revision control tools for a while now, but I didn’t really reach enlightenment until a few months ago when I read Steve Losh’s A Guide to Branching in Mercurial. I highly recommend it. My team now makes heavy use of named branches in Mercurial. Turns out we used branches a fair amount in Subversion and so the named branch workflow was a good fit for us. The fact that everyone had felt the pain of merging svn branches helped to motivate the switch to mercurial as well.

I used the hg convert extension to copy all of our history and a few important branches from subversion to mercurial. Besides the output of hg help convert, my old friend Rock’s Branches – Subversion Conversion to Mercurial, Part 2 helped me understand that process. Creating splicemaps to get merge information from subversion to mercurial was an important concept. I was confused on the syntax for a bit (convert could use some better error messages), but I figured it out eventually. The branchmaps were cool too, because we did have a badly named branch in subversion that we were able to give a better name in the conversion process.

It’s amazing what a good revision control tool does to you. With old clumsy revision control my mode of operation was just stashing changes to files, mainly so that I could hopefully go back to something that was working if needed. It was just a big undo button, in a way. I started noticing our very smart Linux kernel hacker software guys talking about linear history and clean cohesive changesets. Changesets where only one feature or bug was affected at at time. Changesets that showed a clear step-by-step process to completing a feature or fix. They scoffed at commits with messages like, “checkpoint: it compiles now.” At first I thought, “snobs,” but then I realized that mercurial provides tools that actually make it pretty easy to mess with your changes before pushing them to a public repository. And why not? When you are working in your own private local repository, why shouldn't you make sure everything looks neat and polished before going public with it? I started playing with the rebase and histedit mercurial extensions. Most of the software guys here swear by mercurial patch queues, but that just sounded archaic and complicated to me. I had some limited success with histedit, but recently I had another epiphany. Patch queues are actually pretty amazing. Again, Steve Losh helped with A Git User’s Guide to Mercurial Queues, but also just trying them out and seeing how nicely integrated with mercurial they are really helped a lot. I hadn’t realized that they were actually pretty darn easy to use, and so very flexible.

With Mercurial, revision control is no longer just a place to stash code, it’s a code editing tool all of it’s own.

Comments

Popular posts from this blog

SystemVerilog Fork Disable "Gotchas"

'git revert' Is Not Equivalent To 'svn revert'

Put /etc Under Revision Control (with git)