This wiki document explains how to setup Mercurial on Ubuntu. The intended audience is experienced Linux users and system administrators.
If you are new to Mercurial this section provides a quick introduction.
Mercurial is a fast, lightweight Source Control Management system designed for the efficient handling of very large distributed projects.
It is assumed that you are aware of how to run Linux commands, edit files, start/stop services in an Ubuntu system. It is also assumed that Ubuntu is running, you have sudo access and you want to use Mercurial software.
It is also assumed you have an internet connection.
Scope of this document
To install and configure Mercurial, as well as to install some useful extensions
Mercurial is included in the Universe repository - activate this repo first (if you haven't already). Once you've finished simply execute. We will also install meld, which is a graphical merge tool useful for resolving conflicting changes.
$ sudo apt-get install mercurial meld
If it fails reporting dependencies, please locate the packages and install them. If it reports any other issues, please resolve them. If you cannot resolve the issue, please refer the mailing list archive of those packages.
Installation from source
If you already have a version installed, remove it.
sudo apt-get remove mercurial
You may need to sudo apt-get purge mercurial instead of remove. Purge will delete configuration files, which remove keeps.
Get the latest tarball from http://mercurial.selenic.com/release/. We will call the file mercurial-ver.tar.gz, e.g. mercurial-1.4.1.tar.gz. Extract it to a directory:
tar xf mercurial-ver.tar.gz cd mercurial-ver/
Install to the local directory to make sure everything works:
make local ./hg debuginstall ./hg version
If that's OK, use checkinstall (see CheckInstall) to make a .deb package. For the summary, put something descriptive like "Mercurial distributed revision control". Accepting all of the defaults is usually sufficient.
N.B. the version must have numbers in it. If you're using a snapshot, you will probably want to put the date in there (e.g. 20091208).
0 - Maintainer: [ root@host ] 1 - Summary: [ Mercurial distributed revision control ] 2 - Name: [ mercurial ] 3 - Version: [ 1.4.1 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ mercurial-1.4.1 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ mercurial ]
If all goes well, you should have a new mercurial installed.
cd ~ # there was an hg in mercurial-ver/, remember? hg version
Mercurial keeps system wide configuration options in the file /etc/mercurial/hgrc and user configuration options in ~/.hgrc (in your home directory). We will write some user configuration options to ~/.hgrc to tweak how Mercurial works.
Open an editor and Copy and Paste the following into ~/.hgrc:
# Mercurial configuration file # See hgrc(5) for more information # User Interface settings [ui] username= Your Name <firstname.lastname@example.org> editor=nano merge=meld # Enabled extensions [extensions] hgext.gpg= hgext.convert= # GPG extension settings [gpg] key=<your private gpg key>
This sets the default username so that your name will show up on changesets you issue, changes the text editor to nano (default is vi) and sets meld as the merge program. This also enables some useful extensions: GPG allows changesets to be cryptographically signed, while Convert allows Mercurial repositories to be created from existing CVS, SVN, or git repositories.