--- title: Installing Mercurial slug: Installing_Mercurial translation_of: Mozilla/Mercurial/Installing_Mercurial ---
{{ Note('If you have not yet read the Mercurial basics do so now, or see Mercurial for other resources.') }}
We recommend running a Mercurial no older than version 2.8. Version 2.9 or greater is highly recommended, as there are numerous bug fixes and performance enhancements.
apt-get
, emerge
, port
, yast
, or yum
to install software, just do the usual. If this gives you an old version (pre-1.5 -- check with hg version
), you can update it using easy_install
as follows:
sudo apt-get install python-setuptools python-dev build-essential sudo easy_install -U mercurial
sudo yum install python-setuptools python-devel.i686 sudo easy_install -U mercurial
You should configure Mercurial before submitting patches to Mozilla.
If you will be pulling the Firefox source code or one of the derived repositories, the easiest way to configure Mercurial is to run the mercurial-setup mach command:
./mach mercurial-setup
This command starts an interactive wizard that will help ensure your Mercurial is configured with the latest recommended settings. This command will not change any files on your machine without your consent.
If you don't have the Firefox source code available, you should edit your Mercurial configuration file to look like the following:
[ui] username = Your Real Name <user@example.com> merge = your-merge-program (or internal:merge) [diff] git = 1 showfunc = 1 unified = 8 [defaults] commit = -v
On Windows, these settings can be added to $HOME\.hgrc
or $HOME\Mercurial.ini
, or, if you'd like global settings, C:\mozilla-build\hg\Mercurial.ini
or C:\Program Files\Mercurial\Mercurial.ini
. On UNIX-like systems, they should be in your $HOME/.hgrc
file.
You can configure the editor to use for commit messages using the editor
option in the [ui]
section or by setting the EDITOR
environment variable.
If you are trying to access the repository through a proxy server, see these instructions.
After installing, choose a merge program. Seriously. Do it now. If you don't, Mercurial will choose one for you and spring it on you when you least expect it.
A reasonable thing to do is to set ui.merge=internal:merge
in the Mercurial configuration file (see below), which makes Mercurial try to merge changes and add the conflict markers (a la CVS) to the files that couldn't be merged.
Under Ubuntu, you can install meld package, then in in the Mercurial configuration file (see below) set ui.merge=meld
You can see the list of merge conflicts by looking for "merging ... failed!" in the update output.
If you're on Linux and you have kdiff3 installed, you probably want to configure kdiff3 as a merge tool. (It's better than meld because it will actually resolve a bunch of the conflicts without prompting you, generally quite accurately.) You can do this by adding the following lines (which come from contrib/mergetools.hgrc
in the Mercurial distribution):
[merge-tools] kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output kdiff3.regkey=Software\KDiff3 kdiff3.regappend=\kdiff3.exe kdiff3.fixeol=True kdiff3.gui=True
There's a number of extensions you can enable. See http://mercurial.selenic.com/wiki/UsingExtensions. Almost everyone should probably enable the following:
These can all be turned on by just adding this to your .hgrc file:
[extensions] color = rebase = histedit = progress = transplant = pager = mq = [defaults] qnew = -U [mq] plain = True
In addition, there are some 3rd party extensions that are incredibly useful for basic development:
hg qcrefresh
qrefresh
, qnew
, qrename
, qdelete
, qimport
, and qfinish
to commit to your versioned patch queue automatically. This can be done through arguments to the commands, or automatically if you edit your .hgrc to include:
[mqext] mqcommit = autoIt also includes commands to suggest reviewers (
reviewers
) and a bug component (components
) for your patch, to find bugs touching the files you are modifying (bugs
), to show a patch (qshow
), and to show what files the current patch touches (qtouched
).hg trychooser
hg qimport bz://1234567
hg bzexport -i 1234567
Installing these is fairly easy. You'll just need to find a place on your system to store the extensions, and clone the extension repos into it:
hg clone https://bitbucket.org/edgimar/crecord hg clone https://bitbucket.org/sfink/mqext hg clone https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz git clone https://github.com/pbiggar/trychooser
And then add then to your .hgrc file
[extensions] qcrecord = /path/to/crecord/crecord mqext = path/to/mqext qimportbz = path/to/qimportbz trychooser = path/to/trychooser/trychooser
If you have access to the try server you may want to configure Mercurial so you can refer to it simply as "try", since it can be useful from all your trees. This can be done by adding this to your ~/.hgrc (or Mercurial.ini):
[paths] try = ssh://hg.mozilla.org/try/
You can also configure short names like this that are specific to a particular repository by adding a [paths] section to the .hg/hgrc file within a repository. There are two magic names, "default" and "default-push", which are used as the default push/pull targets. (If "default" is specified and "default-push" is not, "default" is used for both.)
Alternatively, you can install the trychooser extension (older version).
{{ languages( { "fr": "fr/Installation_de_Mercurial" } ) }}