Mercurial and Distributed Code Management

Spent a few hours tonight setting up a very simple Mercurial repository and tested it for distributed code development. Using cron jobs and 3 temporary user ids, the only file is modified in the respective local repositories of the users over a period of time. When the changes from all these repositories is pulled into a new repository, the tip/head creation is as smooth as I can imagine. Once the tip and heads are created, the status looked like this:

bash-3.00$ hg heads
changeset: 38:f08a4549a52e
tag: tip
user: hgusr3@localhost
date: Thu Feb 07 01:20:00 2008 +0530
summary: test commit

changeset: 29:6337c050747e
user: hgusr2@localhost
date: Thu Feb 07 01:24:00 2008 +0530
summary: test commit

changeset: 20:abc6f51d4958
user: hgusr1@localhost
date: Thu Feb 07 01:28:01 2008 +0530
summary: test commit

changeset: 10:25b7c063d15c
parent: 9:65dec58603a6
parent: 7:fa096b952604
user: spurthi@localhost
date: Thu Feb 07 00:10:11 2008 +0530
summary: test commit

bash-3.00$

After I manually merged all the revisions, the result looked great!

Wed Feb 6 23:33:02 IST 2008
Wed Feb 6 23:36:37 IST 2008 by spurthi
Wed Feb 6 23:36:39 IST 2008 by spurthi
Wed Feb 6 23:36:40 IST 2008 by spurthi
Wed Feb 6 23:44:46 IST 2008 by spurthi
Wed Feb 6 23:48:00 IST 2008 by hgusr1
Wed Feb 6 23:50:00 IST 2008 by hgusr3
Wed Feb 6 23:54:00 IST 2008 by hgusr2
Wed Feb 6 23:58:00 IST 2008 by hgusr1
Thu Feb 7 00:00:00 IST 2008 by hgusr3
Thu Feb 7 00:04:00 IST 2008 by hgusr2
Thu Feb 7 00:08:00 IST 2008 by hgusr1
Thu Feb 7 00:10:00 IST 2008 by hgusr3
Thu Feb 7 00:14:00 IST 2008 by hgusr2
Thu Feb 7 00:18:00 IST 2008 by hgusr1
Thu Feb 7 00:20:00 IST 2008 by hgusr3
Thu Feb 7 00:24:00 IST 2008 by hgusr2
Thu Feb 7 00:28:00 IST 2008 by hgusr1
Thu Feb 7 00:30:00 IST 2008 by hgusr3
Thu Feb 7 00:34:01 IST 2008 by hgusr2
Thu Feb 7 00:38:00 IST 2008 by hgusr1
Thu Feb 7 00:40:00 IST 2008 by hgusr3
Thu Feb 7 00:44:00 IST 2008 by hgusr2
Thu Feb 7 00:48:00 IST 2008 by hgusr1
Thu Feb 7 00:50:00 IST 2008 by hgusr3
Thu Feb 7 00:54:00 IST 2008 by hgusr2
Thu Feb 7 00:58:00 IST 2008 by hgusr1
Thu Feb 7 01:00:00 IST 2008 by hgusr3
Thu Feb 7 01:04:00 IST 2008 by hgusr2
Thu Feb 7 01:08:00 IST 2008 by hgusr1
Thu Feb 7 01:10:00 IST 2008 by hgusr3
Thu Feb 7 01:14:00 IST 2008 by hgusr2
Thu Feb 7 01:18:00 IST 2008 by hgusr1
Thu Feb 7 01:20:00 IST 2008 by hgusr3
Thu Feb 7 01:24:00 IST 2008 by hgusr2
Thu Feb 7 01:28:01 IST 2008 by hgusr1

For my current need, I need an easier (and automated) merge tool. Once I find one, the use of Mercurial can be extended beyond code management.

First Look at Mercurial

Wanted to play with Mercurial a bit. Have a Sparc Desktop that runs with Solaris 10, so wanted to use it for this. When I checked the home page of Mercurial, the binary packages of Solaris-Sparc are downloadable from BlastWave. This particular Desktop was not setup to work with pkg-get earlier, so I followed the instructions here to set it up. Once setup, with a simple command:

pkg-get -i mercurial

I could get Mercurial and all the dependencies downloaded and installed in less than 15 minutes. Simple and smooth!

Once installed, I religiously started following the tutorial for Mercurial. During Step 2 (TutorialClone) I stumbled a bit. I am behind a firewall and need to use a proxy to get to the external repository on http://www.selenic.com/. A quick read of the hgrc manpage suggested that I need to have a temporary hgrc file with right configuration.

I initially started with a ~/.hgrc file. Here is a snippet of the file:

[http_proxy]

host = mycache.india:8080
no = jamesbond007,jamesbond007.india

The configuration is very simple. I added the last line because I wanted to serve a repository off jamesbond007 and didin’t want that traffic to flow thru a proxy.

Once I created the clone, I moved the contents of ~/.hgrc file to /MYREPOSITORY_DIR/.hg/hgrc file so that these configurations are localized to that particular repository.

Cool and Simple start!