How to use Churn extension of Mercurial

The Churn extension is useful to have on repositories shared by many authors. It shows a simple histogram of committed changes, along with author name.

  • To enable the Churn extension, add this line to your hgrc:
churn =
  • Using churn is straightforward:
$ hg churn 800 ******************************** 420 *****************

Tried with: Mercurial 2.8.2 and Ubuntu 12.04

About these ads

How to use Shelve extension of Mercurial

The Shelve extension of Mercurial is useful to temporarily store away your uncommitted changes and then restore them back. For example, if you are working on some changes, and before you commit it, someone comes in and asks you to test something on an earlier version. You can shelve away your changes, finish the testing and unshelve the changes and continue.

  • The Shelve extension needs Mercurial 2.8 or later. If you have an older version of Mercurial, install the latest version.

  • If your Mercurial installation does not include the Shelve extension, it can be installed from PyPI using PIP:

$ sudo pip install hgshelve
  • Enable the extension by adding this line to your hgrc:
shelve =
  • To shelve your uncommitted changes:
$ hg shelve

It will be stored using the name default. You can provide other names if you wish.

  • To unshelve these changes later:
$ hg unshelve

Tried with: Mercurial 2.8.2 and Ubuntu 12.04

How to add symbolic name for Mercurial repository

When you clone a repository in Mercurial, it creates a file .hg/hgrc in the new clone repository. Typically, this has the following lines:

default =

That is, it has the login, the source location (directory or internet domain), the repository owner and finally the repository name. This assigns a symbolic name of default to this repository. After this any push or pull command is done with this repository.

If you created a new Mercurial repository and want to push it to another existing repository, then the command is:

$ hg push

If you want to push or pull without having to specify the repository, then just create a .hg/hgrc file and add the above lines to it.

If you want to add other repositories to push-pull from, add them on separate lines with a different symbolic name, not default:

default =
bkp =

You can push-pull from that repository using the symbolic name you have given it:

$ hg pull bkp

Tried with: Mercurial 2.0.2 and Ubuntu 12.04 LTS

How to view files ignored by Mercurial

It is sometimes useful to see which files are being ignored in a Mercurial repository. For example, there might be some .hgignore rules that might be getting applied without your full knowledge. Such files will not be tracked or committed.

Seeing the list of ignored files in a local repository is easy:

$ hg status --ignored

Or if you prefer the short version:

$ hg st -i

Tried with: Mercurial 2.0.2 and Ubuntu 12.04 LTS

MercurialEclipse plugin for Eclipse

If you use Eclipse as your IDE and Mercurial as your version control system, then you might find the MercurialEclipse plugin useful. If you add, remove, rename or move source files using Eclipse, it is a pain to synchronize these changes to the underlying Mercurial repository. If you use the MercurialEclipse plugin, all can make all the changes you wish directly to the repository.


Go to Help > Install New Software > Add and add to Location and click OK. Pick the Stable release and proceed with the rest of the installation. Restart Eclipse after the plugin is installed.


The big problem I have with MercurialEclipse is that it will not work with existing repositories. You have to clone an existing repository using MercurialEclipse, so that it can create a project of that in your Workspace. This is the only way to begin using it. To do this, go to File > New > Project > Mercurial > Clone Existing Mercurial Repository. Provide the URL or local location and create the project.

To do any Mercurial operation, click on the relevant project, directory or source file in Project Explorer and choose Team. All the relevant Mercurial operations can be seen listed in this right-click menu.

The status of the files in the repository are indicated by icon overlays in Project Explorer. You can do almost all the Mercurial operations from inside Eclipse, including viewing the history log and graph, committing, changing branches and so on.

Tried with: MercurialEclipse 2.1.0, Eclipse 3.7.2 and Ubuntu 12.04 LTS


If you use Mercurial or Git at the shell, cdiff is a useful tool to have around. By default, hg diff or git diff is displayed in the classic diff format. This displays the before-after changed lines one below the other. Personally, I find this very confusing. I very much prefer the side-by-side diff view used in GUI diff programs. cdiff is a great way to get this side-by-side diff view at the shell in full colors!


cdiff is a Python module that can be installed from PyPI using this command:

$ sudo pip install cdiff

Note: Do not confuse this package with the colordiff package that is available in Ubuntu repositories. That is something else!


Just invoke cdiff in any subdirectory of a Mercurial or Git repository. To get side-by-side view use cdiff -s

Tried with: cdiff 0.9.2, Python 2.7.3 and Ubuntu 12.04 LTS