Sunday, 6 July 2014

Installing Mercurial on Linux


There are many source code versioning tools. Some of them which I have previously used are perforce(p4), git, svn. There are more like cvs, mercurial and the list goes on.... In this post we will see how to install and configure mercurial.

Mercurial is a free, distributed source control management tool. It efficiently handles projects of any size and offers an easy and intuitive interface. (official site)

Mercurial is a cross-platform, distributed revision control tool for software developers. It is mainly implemented using the Python programming language, but includes a binary diff implementation written in C. It is supported on MS Windows and Unix-like systems, such as FreeBSD, Mac OS X and Linux. Mercurial is primarily a command line program but graphical user interface extensions are available. All of Mercurial's operations are invoked as arguments to its driver program hg, a reference to the chemical symbol of the element mercury. (More on Wiki)


You can easily to the installation using a package manager

sudo apt-get install mercurial

But for me it installed a very old version (2.0.2) which is clearly not the way to go. So you can install the latest version as follows - 

sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U mercurial

This installed the latest version for me (3.0.1). You can view the version installed by

hg version

Configuration file for the same can be found in  /etc/mercurial/hgrc. You can edit it to suit your requirements.

I have added external diff program called kdiff3 ( How to Install Kdiff3 on Ubuntu  ). So my hgrc file contents are as follows

# system-wide mercurial configuration file
# See hgrc(5) for more information

kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output

Important Links

How to Install Kdiff3 on Ubuntu


Subversion, Git, Mercurial and others support three-way merges (combining mine, theirs, and the "base" revision) and support graphical tools to resolve conflicts.

Which tool do we use ?  In this post I will show how can we install KDiff3.
 It is an open source cross platform tool.



  1. Download the Kdiff3 tar file from the sourceforge repos, then extract the tar file. The sourceforge link for the Kdiff3 project.
  2. Extract the tar.gz file using tar command

    tar -xzf kdiff3-0.9.98.tar.gz
  3. Make sure you have QT4 installed . If not installed you can install it with following command -

    sudo apt-get install libqt4-dev
  4. After extracting go into the “src-QT4″ directory and compile

    cd kdiff3-0.9.98/src-QT4
    sudo make install
  5. Now you should be able to launch the program by typing kdiff3 in the console.

Important Links

t> UA-39527780-1 back to top