Mercurial vs. SVN

As I’ve been starting on a new project recently, I’ve been delving into Mercurial (hg) as an alternative to Subversion (svn).

I’ve been using svn for about 3 years now, and – for the most part – it has been way better than Visual Source Safe (whatever last version I used…it sucked), it clearly has some pain points that make daily workflows difficult.  The most important of these are the speed of commits, the fact that a commit is global, reverting to a version, and branching/merging (painful…so painful).

hg addresses each of these pain points:

  • Speed of commits and local commits: Mercurial has two separate concepts of commit and push.  A commit in hg creates a local commit as opposed to a global commit in svn.  This is useful because you can work->work->commit->work->commit->work->revert->commit without affecting anyone else’s work stream.  In other words, you don’t have to wait to commit until you have flawless, working, compiling code.  You can commit as much as you want and keep your work intact; this is a big win as it encourages experimentation.  When you’re ready to share your code, a push operation (the equivalent of a svn commit) pushes it to a shared location for others to pull.  Of course, to some degree, you can accomplish this with svn as well using a branch, but…
  • Branching/merging: OMG, so much easier and more intuitive than svn.  I can’t believe it.  In comparison, svn is a giant charlie foxtrot.  Branching and merging in svn pre-1.5 was an exercise in futility.  It was extremely difficult to remember the right procedure (always requiring a lookup to the docs) and very much error prone.  So difficult, in fact, that it discouraged branching for fear of wasting a good half day trying to merge it back in later.  Maybe it’s better with 1.5?
  • Reverting to a version: ever try it in svn?  ‘Nuff said.  It’s counterintuitive and always confuses the heck out of junior devs or devs new to svn.

I’ve only been using it for a few days now (primarily TortoiseHg), so perhaps hg has just as many warts as svn, but I’m going to stick with it and find out.

Some good resources on hg/git vs. svn (or DCVS vs CCVS):

I’ll post new entries as I learn more about hg in daily use 🙂

P.S. WebFaction is a pretty awesome webhost.  For the low, low price of some $10 a month, I can host my own hg repository, svn repository, Trac, and (note: not or) my web app.  Hot damn, that’s awesome!  Although svn was significantly easier to set up with WebFaction than hg, I’ve read that they are close to officially supporting hg and it should be just as easy in the future.

You may also like...