Branching in Mercurial

April 3, 2010

There is a good article A Guide to Branching in Mercurial.

Basically, it says that there are a few ways to do branching, so just choose one and work with it. I chose Branching with Named Branches and it was really quite simple to make a simple branch and merge it with the default tip.

Basically just call hg branch myFeature and you mark your local working copy as being a branch with a name “myFeature”. If someone clones your copy (you should try cloning your copy in your local file system), the it will default to default tip, not to your branch.

After some development time, you must synchronize both branches. You do this simply with hg pull or hg push command. It’s just a matter of whether you want to push your changes to other repo, or get others changes from another branch.

When you update your local copy, it is interesting to start TortoiseHG repository explorer and see that there are two separate development trees. To merge those, you have to call hg merge -r revNR .  RevNR is the other branches tip revision number.

Note that while working this way, you wont get “branch <yourBranch> has two heads”.  AFAIK, this might happen if two separate developers would commit into the same branch, and then would try to merge.


Mercurial is decentralised version control. I chose to use it because of speed (compared to svn) and decentralized nature.

To convert an existing svn repository to hg repo we can use Convert extension. First you need to configure it by adding appropriate tags to .hgrc file  (read about this in the convert extension page).   The location of the .hgrc file depends on your operating system, and where to find it  windows you can read here.

When everything is set up, open your console window, cd to the dir where your checked out repository resides and just type

hg convert nameOfYourSvnRepDir

This will convert your subeversion repo to directory named nameOfYourSvnRepDir-hg

Happy hg’ing!

SourceGrid 4.22 released

December 12, 2009

SourceGrid 4.22 has been released for a while.

The most interesting changes are these:

  • QuadTree implementation for spanning cells. This improves performance 2 to 5 times when working with spanned cells. I used simple library found on codeproject.
  • Source code repository was moved away from CodePlex to BitBucket . New repository is here.

The reason for doing this is terrible support svn at CodePlex. Read more in another post. BitBucket is a site inspired by GitHub and provides Mercurial DCVS support. Hopefully this will encourage other people to experiment with this project.