Friday, April 11, 2008

Mercurial in NetBeans - Installing Mercurial in Windows

Mercurial is a distributed version control system. It allows us to maintain source versions in a distributed way. This means we can maintain version information locally in a Mercurial repository and can share this information with others easily. Typically in big projects the topology of sharing of repositories get planned and the repositories are laid out like a tree.

There is one main repository maintained and the developers clone the repositories on their work stations. Cloning means making a replica of the repository on another place. This makes the full Mercurial repository available with the source on local workstation. The origin of the clone is configured as default push path.

Mercurial can be taken as a source control repository server available with in local workstation. This server can share its data with up-link server from where it was cloned in an easy command called as push.

Distributed version control system has become popular lately due to its ease of use all the goodness of copy-merge type of systems and also distributed architecture. This means no central server from where all will have to checkout the projects. This becomes a distributed tree of the project with each developer having his own copy of the server and these servers then collaborate with each other.

NetBeans IDE has support for Mercurial. Actually even the NetBeans code base is now shifted to a Mercurial repository.

Let us see installation of Mercurial system on Windows. Useful information is available on the MozillaWiki Mercurial page. I figured out some missing points to make them work which we will see. We will need some software installers as follows:

1. Mercurial Windows Binary
2. ActiveTcl Installer for hgk
3. hgk.tcl script for "hg view" GUI interesting visualization of repository
4. TortoiseHg Windows Shell client installer

The installation of Mercurial Binary is straight forward.


For windows the installer starts a wizard.


We need to keep on responding with Next. The last page asks whether we want the windows path to be updated. This is a good idea and shall be checked out so the Mercurial command becomes available on command prompt from all the directories.


Once Mercurial is installed I checked the installation by opening a command prompt and typing hg command. It showed the usual output from Mercurial command about the usage of Mercurial. This ensures that I have a good Mercurial installation on my Windows machine now.


Mercurial and GIT are very similar systems. GIT people use a command gitk for visualization of the GIT repository and this command is also available in Mercurial as "hg view". In windows making this command work needs Tcl installed. ActiveTcl distribution makes the Tcl toolkit available in windows.

ActiveTcl provides a installation wizard.


The wizard is simple and easy to follow.


The Registry Settings part is important and registering the tcl extension is important for the tcl files to work.


The hgk file shall be renamed to hgk.tcl and copied to the Mercurial directory. As the Mercurial directory is already in the windows path this will make the hgk file available in path.


Mercurial has a extensions system to work with external command. In the Mercurial.ini file we need to add one line as shown for hgk to work as an extension


At the end of the Mercurial.ini file add one [hgk] section as shown to make the hgk.tcl file path available to Mercurial.


This will ensure that we can run "hg view" command now. lastly we will install the TortoiseHg shell client for windows. Tortoise products are superb products for CVS, SVN and now also for Mercurial. They make task like creating repositories and working with them piece of cake.


Once you start the installer the wizard will ask questions and in minutes you will have tortoise shell client installed on windows.


Let us see how to work with the Mercurial repositories in the next post. We will use Mercurial repositories in NetBeans IDE to check the Mercurial support from NetBeans.

with regards
Tushar

No comments:

Post a Comment