Managing Software Projects with Mercurial
The Linux kernel used to be hosted using a version control system and code-
hosting service that was free to use, but it wasn’t open source. This was often
a source of tension among free software advocates within the Linux
community. Then that service announced it was moving to a for-payment plan
and gave some time for transition. Out of that decision, two new version
control systems were birthed. Mercurial is one of them, and Git is the other.
Both were initially written to host the code for the Linux kernel. Because Git
was originally written by the main kernel developer himself, Linus Torvalds
(in just 2 weeks), it won out. However, the wider open source development
community was the ultimate winner as two interesting and useful version
control systems were born.
Mercurial was created by Matt Mackall, who still leads its development.
Mercurial uses a distributed architecture and is designed to be fast, even when
working with large code bases. Its commands are similar to those of
Subversion, which makes transition and initial use quick and easy. One
interesting feature is that Mercurial is extensible; extensions may be installed
from the project’s wiki or written by users to change how things work or to
add features without changing the original code. Source code control is done
from the command line, as shown in the following examples. You need to
install Mercurial from the Ubuntu software repositories, where it is called
mercurial.
NOTE
The chemical symbol for mercury is Hg. This is why Mercurial commands
use hg.
To create a new repository, create an empty project directory:
Click here to view code image
matthew@seymour:~$ hg init your_project_name
Then, to add your files to the directory, cd into the directory if you are not
already in it, and enter the following:
Click here to view code image
matthew@seymour:~$ hg add
To check in code the first time or after you have made changes, use the -m
flag to add a note, which is a good idea so that others know what the commit
contains:
Click here to view code image