MDN’s new design is in Beta! A sneak peek:

Instalação de Mercurial

Ocorreu um erro de código nesta página. Enquanto este é resolvido pelos editores do site, pode ver o conteúdo parcial abaixo.

Esta tradução está incompleta. Por favor, ajude a traduzir este artigo do Inglês.

{{ Nota }}

Please refer to Mercurial para Mozillians em ReadTheDocs for current best-practices around Mercurial, including many helpful extra tools and guidelines that make using Mercurial fast and easy.


See Installing Mercurial from the Mozilla Version Control Guide.

Configuração básica

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:

username = Your Real Name <>
merge = your-merge-program (or internal:merge)
git = 1
showfunc = 1
unified = 8

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.

Outras dicas de configuração

Unir programa

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.

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):

kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output


There's a number of extensions you can enable. See 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.

These can all be turned on by just adding this to your .hgrc file:

color = 
rebase =
histedit =
progress =
transplant =
pager =

In addition, there are some 3rd party extensions that are incredibly useful for basic development:

Mozilla-specific functionality to aid in developing Firefox/Gecko.
Automatically creates a try commit message and then pushes changes to Mozilla's Try infrastructure. Just run:
hg trychooser
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
hg clone
hg clone
git clone

And then add then to your .hgrc file

qcrecord =  /path/to/crecord/crecord
mqext =  path/to/mqext
qimportbz =  path/to/qimportbz
trychooser = path/to/trychooser/trychooser

Configuração do repositório de testes

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):


try = ssh://

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.)

Alternativamente, pode instalar a extensão trychooser (versão antiga).

Etiquetas do documento e contribuidores

 Contribuidores para esta página: mansil
 Última atualização por: mansil,