See Installing Mercurial from the Mozilla Version Control Guide.
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:
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 <firstname.lastname@example.org> 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\Mercurial.ini, or, if you'd like global settings,
C:\Program Files\Mercurial\Mercurial.ini. On UNIX-like systems, they should be in your
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.
Other configuration tips
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
You can see the list of merge conflicts by looking for "merging ... failed!" in the update output.
Configuring kdiff3 as a merge tool
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:
- color - Colorize terminal output
- histedit - Provides git rebase --interactive behavior.
- pager - Feed command output into a pager (like less)
- progress - Draw progress bars on long-running operations.
- rebase - Ability to easily rebase patches on top of other heads.
- transplant - Easily move patches between repositories, branches, etc.
- mq - Easily maintain a series of patches on top of your tree, or even multiple different sets of patch queues. (see the Mercurial Queues guide to learn more)
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:
- Mozilla-specific functionality to aid in developing Firefox/Gecko.
Provides a nice easy gui for splitting up patches into chunks. For a given patch you can type:
qfinishto 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 (
Automatically creates a try commit message and then pushes changes to Mozilla's Try infrastructure. Just run:
Import patches from Bugzilla. Creates a filename and commit message for you based on the bug's metadata.
hg qimport bz://1234567
Export patches to Bugzilla. There are quite a few optional arguments here to create new or update existing bugs with the attment, as well as auto matically request reviews. Type hg help bzexport for a full list but the basic syntax is:
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
Configuring the try repository
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.)