Note:

This page is primarily intended for developers of Mercurial.

Contributing Changes

How to help us improve Mercurial's code.

1. Submission checklist

Please double-check your patch meets the following guidelines (explained below) before hitting send:

2. Getting started

Start by cloning a copy of Mercurial's main repo:

hg clone http://selenic.com/hg

You'll also want to read the following pages:

Other pages you may find important:

3. Organizing patches

{X} If your first submission is not 'minimal', you will probably be sent back here. Save yourself time and start small!

If you're making a large change, we're probably going to want it broken into a series of smaller patches (see OneChangePerPatch). This makes for easier review and tests both for us and for you. This can be tricky at first and you might find tools like MQ and record useful in this process.

Each patch in a series should:

<!> Do not mix formatting changes, organizational changes, or multiple functional changes in the same patch!

Things to consider:

3.1. Editing history

You will almost certainly find it necessary to do some form of history editing to generate clean commits, especially after you get your first review feedback. There are multiple tools of varying degrees of power available for this purpose:

4. Coding style and testing

<!> If you send a patch with an underscore in a variable name, we'll know you haven't read this page!

5. Patch descriptions

It's important that you describe your patch. Patch descriptions should be in the following format:

opener: check hardlink count reporting (issue1866)

The Linux CIFS kernel driver (even in 2.6.36) suffers from a hardlink
count blindness bug (lstat() returning 1 in st_nlink when it is expected
to return >1), which causes repository corruption if Mercurial running
...

Patch descriptions should be aimed at helping the reviewer understand the issue you're addressing.

Try to use the form "When I tried to do X, I got result Y, but the result should be Z". This is better than "X does not work" which assumes a common understanding of what it means for X to work and leaves the reader to intuit what Y and Z might have been.

Try to answer the following, where appropriate:

6. Emailing patches

/!\ Don't send your patch to the BugTracker - it can't be reviewed there, so it won't go anywhere!

We like to receive changes as patches by email. This allows us to review patches, give feedback, and track which patches need attention.

Because this is a community project and our developers are very busy, patches will sometimes fall through the cracks. If you've gotten no response to your patch after a few days, feel free to resend it.

6.1. Mailer issues and patchbomb

As mentioned above, patches should be included in the body of emails to make it easy for developers to review and apply your patches. Some mailers make this difficult by mangling the whitespace in patches or similar. If you have trouble sending clean patches or are sending more than a couple patches, you should probably set up the patchbomb extensions which automates the process.

Add something like the following to your .hgrc:

[extensions]
patchbomb=

[email]
method = smtp
from = Ada Lovelace <adalovelace@gmail.com>
to = mercurial-devel@selenic.com

[smtp]
host = smtp.gmail.com
port = 587
tls = starttls
username = adalovelace@gmail.com

(See the hgrc manual for more SMTP configuration options).

Then run the following to do a dryrun test:

$ hg email --test <change1> <change2> ...

Notable options:

7. Flow control

A large fraction of patches are reviewed by mpm, who attempts to make sure no submissions fall through the cracks. When he gets backlogged, his time to reply goes up significantly. If you're planning on sending more than a couple patches, it is important to pace your submissions.

The state of mpm's email backlog can be seen here. The first number indicates the number of messages, the second is the number of patches, and the third is the age of the oldest patch in days. If the second number is greater than 100, please have extra patience and send only small sets of patches between replies.

Please also make sure the state of your patches in Patchwork is updated. This system is strictly secondary to the mailing list, but is helpful to other reviewers for finding patches that still need review.

8. Etiquette and advice

9. See also


CategoryDeveloper