Thursday, 21 April 2011

Mercurial In Ubuntu

Since I have moved to ZeroTurnaround I had to learn a lot of new and interesting things. Most of them are very simple to write about, but as time passes I finally thought up the things, I could share with you.

We use Mercurial as SCM. So here is a small tip for ubuntu users how to configure hg.

Mercurial is available to install through repository

$ sudo aptitude install mercurial

So now as it is installed, we can configure it. Mercurial reads configuration data from several files, if they exist. To list them use:

$ hg help config

Now we will edit the $HOME/.hgrc file to add there some user information, authentication and enable plugins. A configuration file consists of sections, led by a [section] header and followed by name = value entries (sometimes called configuration keys)

[ui]
username = Firstname Lastname <firstname.lastname@example.net>

Here we introduced ourselves. The section is [ui] and ui.username is typically a person's name and email address. If this field is not declared in hgrc, you will have to enter it manually every time you commit.

[auth]
foo.prefix=*
foo.username=firstname.lastname@example.net
foo.password=SecretPassword123

The [auth] section allows you to store credentials for http authentication, I hate entering username and password every time I pull or push. You can store several different credentials for different servers here. They will be grouped by the part before the . (full stop, foo - in my example). And the auth.prefix will determine, which credentials should be used for what http address. It should be either * or a URI with or without the scheme part. In my example 1 and the same credentials are used for all addresses.

[extensions]
fetch = 
color =
#this extension will get loaded from the file specified
myfeature = ~/.hgext/myfeature.py

Mercurial has an extension mechanism for adding new features. To enable an extension, create an entry for it in [extensions] section. There is a list of extensions for Mercurial and you can write one yourself. Extensions bundled with Mercurial does not need anything after the equals sign, but you need to provide the full path to others.

Now that we have configured it a little bit, we can start using. Mercurial tutorial by Joel Spolsky will teach you, how.

No comments:

Post a Comment