Getting Mozilla Source Code Using Mercurial

Revision Information
• Revision slug: Developer_Guide/Source_Code/Mercurial
• Revision title: Getting Mozilla Source Code Using Mercurial
• Revision id: 375505
• Created:
• Creator: jdm
• Is reviewed? Yes
• Reviewed:
• Reviewed by: jdm
• Is approved? Yes
• Is current revision? No
• Comment

Revision Content

Mercurial is a source-code management tool which allows users to keep track of changes to the source code locally and share their changes with others. It is used for the development of Firefox.

Checking out a source tree

There are multiple hg repositories hosted at mozilla.org, see http://hg.mozilla.org/ for the full list.

mozilla-central (main development tree)

Most developers write patches against the mozilla-central tree.

Clone mozilla-central to get a local copy of the repository and then cd into it:

# This may take a while...
hg clone http://hg.mozilla.org/mozilla-central/ src
cd src


Latest successful build

The latest committed changes in your checkout may not build successfully. You may want to get the source code that has passed the automatic tests.

mozilla-inbound (used for landing your patches)

Most developers also maintain a clone of mozilla-inbound, which they use for landing their patches.  You probably want to develop on top of mozilla-central, which tends to be more stable, but you should use mozilla-inbound when your patches are ready to land.  See this page for how checking code into mozilla-inbound works.

hg clone http://hg.mozilla.org/integration/mozilla-inbound/ inbound-src
cd inbound-src


mozilla-aurora (second-stage development tree)

When patches are considered ready for broader testing, they get branched onto mozilla-aurora. This code, while more complete (and, in theory, stable) than mozilla-central, is not yet beta-quality. If you want to build off this branch, you can clone the repository as follows:

# Pull the Mozilla source to the folder aurora-src/ - may take a while
hg clone http://hg.mozilla.org/releases/mozilla-aurora/ aurora-src

cd aurora-src

mozilla-beta (prerelease development tree)

When a new release of Firefox enters beta testing, the code is branched into  mozilla-beta. This code represents the expected next release of the Firefox browser, and should be pretty stable. If you want to build off this branch, you can clone the repository as follows:

# Pull the Mozilla source to the folder beta-src/ - may take a while
hg clone http://hg.mozilla.org/releases/mozilla-beta/ beta-src

cd beta-src


mozilla-release (release tree)

To get the source repository for the current release of Firefox, do the following:

hg clone http://hg.mozilla.org/releases/mozilla-release release-src
cd release-src


comm-central (Thunderbird/SeaMonkey/Calendar)

See Comm-central source code (Mercurial) for further information on pulling and building with comm-central.

L10n repos

If you are creating a new localization based on an already-localized version of a Mozilla project, you will be interested in cloning this code. Code for all l10n projects lives in l10n-central and is organized (in most cases) by the locale's two character ISO code. When cloning, use the same ISO code to name the local directory that will store it. To get this code, do the following:

# Pull the Mozilla source to the folder src/ - may take a while
hg clone http://hg.mozilla.org/l10n-central/your-ISO-code yourISOcode

cd yourISOcode


Bundles

If you have a poor network connection that is preventing 'hg clone' from completing, you may want to try downloading a bundle of the repository you're interested in (which, unlike 'hg clone', can be resumed when network problems interrupt the download).

Up to date bundles of some of the repositories listed at http://hg.mozilla.org/ are available on ftp.mozilla.org:

Bundles for some of the other repositories may also be found by googling. The 'hg pull' you will run later will verify the integrity of the bundle you download.

1. Initialize a new repository (in a directory called 'mozilla-src' here):

mkdir mozilla-src
hg init mozilla-src


2. Un-bundle the bundle file to that repository:

To use the below command in windows, export the \path\to\hg and invoke the command from command prompt.

cd mozilla-src
hg unbundle /path/to/your/bundle.hg

(The unbundle is going to take quite a lot of time)

3. Add the following lines to the file mozilla-src/.hg/hgrc (you may have to create it) so that hg will automatically know where to pull changes from in future (replacing 'mozilla-central' as appropriate):

[paths]
default = https://hg.mozilla.org/mozilla-central/

4. Update the repository to get all the changes since the bundle was created (this step also doubles as a check of the bundle integrity since if its contents are not exactly the same as what's in the official repository then the 'hg pull' will fail):

hg pull

5. Check out a working copy from your new up to date repository:

hg up

Building

By default with no configuration a similar-to-release build is done. If you wish you can configure the build using a .mozconfig file and make -f client.mk. Different OSs have different prerequisites for a successful build, please refer to the build documentation to verify they are available on your build machine.