Joe Doyle's Blog

How I chose between Git and Mercurial

The current popular topic among developers is distributed version control. The current standard is Subversion, which was a nice improvement over CVS. Like most technology, when there are pain points, someone is going to improve on it. That’s where distributed version control systems come in. The two front runners are Git and Mercurial. There are dozens of blog posts about using a DVCS and what’s good about them over Subversion, so I’m not going to talk about that. Instead, this is about the factors in how I chose between them as I migrate away from Subversion.
Here’s what my environment and what I needed:

As a .NET developer, I use Windows.

The repository should be easily accessible over the internet from my servers.

The repository needs to be locked down. The code I write isn’t open source.

The two DVCS’ do quite well with #2 & #3. But one of them does much better at #1 and makes #2 easier. Anyone who has looked at Git or Mercurial knows that Git wasn’t exactly designed with Windows support in mind. It can be used in Windows, and many people do. If it had a native Windows implementation, it probably would have been my choice. This StackOverflow question made it clear, that Git on Windows is not ready for prime time.

Ok, Mercurial it is!

So now to get started. There are tons of good tutorials about getting started. The two places I used were www.hginit.com and the TekPub series Mastering Mercurial. Getting up and running locally is pretty simple. TortoiseHg and VisualHg are on par with their Subversion counterparts, although I still learned about the command line options. I did struggle a bit to have Mercurial import my existing Subversion repositories, but again, a quick search brought up a bunch if pages with the fix.

The next step is to get the repositories up online. The TekPub series had a great walkthrough for getting the hgwebdir.cgi setup. Most of the difficulty is making sure that Python is enabled in IIS, after that it’s permissions that you need to get right. In the past, I played around with PHP and Python a little, so I had done most of those steps before. The overall setup in IIS does require basic authentication as the first level of security. That of course means you need to use SSL to keep the username and password from being sent in clear-text. Luckily, I already have an SSL certificate installed and ready.

Tying up the lose ends

So now I’ve gotten everything setup. I can push and pull from my “master” copy. The one thing that is driving me crazy is that I keep getting prompted for my credentials! I was a little surprised that there weren’t more articles about this. I was led down the correct path from an older post about someone trying to this on Linux. Luckily it translated over directly.

Mercurial on Windows uses INI files for most settings. There are global settings which are stored in the TortoiseHg install folder, and per-user settings in the root of the user’s profile. Here’s the section that needs to be added:

The ‘group’ that prefixes the entries is just a friendly name to group of properties for the authentication. It’s not tied to anything like the server name or repository. These settings will apply to any repository hosted on the server entered in the group.prefix field. After this was saved, I no longer got prompted when I pushed or pulled from the main server.

Moving forward

Now I’m in day-to-day mode. It’s still a little bit of a change in workflow compared to Subversion which I used for the last few years. The branching is really nice and the graph display is a slick feature. I haven’t had to do a complicated merge yet, but I hear it’s a nice experience. I can’t wait.