Differences between revisions 35 and 131 (spanning 96 versions)
Revision 35 as of 2010-10-15 09:00:09
Size: 5644
Editor: abuehl
Comment: recat
Revision 131 as of 2023-04-06 07:59:14
Size: 14569
Editor: RaphaelGomes
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Contributing changes to Mercurial ==
[[MercurialDevelopmentProcess|Mercurial development process]] resembles the one described in KernelPractice. As most free software projects, contributions and feedback are very welcome and even encouraged, but, to make easier to manage those contributions and keep a clean and maintainable code base, these contributions need to follow a review process before entering the main [[Repository|repo]] (see DeveloperRepos).

These are some useful recommendations to increase your chances of getting your contributions accepted (see also '''SuccessfulPatch'''):

 * '''Make sure your description of what the [[Patch|patch]] addresses is complete'''.
  * If using {{{hg export}}}, add the ''description along with the exported patch''.
  * Make also sure your ''description starts with a reasonable one-line summary''. The first line should be like ''<command/module/topic>: <short description> (optional issue number)'', no more than 80 characters in total, no trailing period, and followed by an empty line.
  * Make sure the description is complete and can be read and understood without following external references and without reading the actual patch. Describe why the patch is needed, what the intent with the patch is, and what the consequence of the patch is. Small examples and tables can be useful.
 * '''Send your [[ChangeSet|changes]] as patches to the [[MailingList|mailing list]]''', so other people can comment on them and '''review''' what you're doing.
 * '''Use [[Export|hg export]] or the [[PatchbombExtension|patchbomb extension]]''' to create and send patches, where possible.
  * This will get your name in the changelog without any extra editing and, with patchbomb, email messages will be nicely formatted.
  * We prefer inlined patches over attached patches. It allows reviewer to quote the code when commenting on your patch.
 * '''Send only one patch per email''', as some review tools and processes assume this.
 * '''Inline patches are preferable to MIME-attached copies of patches''', because many mailers cannot quote attachments. Inline patches are thus easier to review. Be warned that many mailers will by default screw up the white space of inline patches, so they will not apply cleanly. This is usually easy to work around, for example by using the patchbomb extension or turning off flowed text in mailers such as Alpine. Note that ''inline patch'' '''doesn't''' mean ''inline attachment'' so don't use `-i` with `hg email`.
 * '''Make sure the patches apply cleanly against the current [[Tip|tip]]''' (either the main or crew repositories are ok).
 * '''Each patch should make sense in and of itself, and not contain pieces of unrelated stuff''' that you noticed and decided to fix up.
 * '''Follow the prevailing coding style''' in the code you're modifying, not what you think it ''ought'' to be. See '''BasicCodingStyle''' for a detailed list.
  * Patches ''should not contain tab characters''.
  * Patches ''should not contain trailing white space''.
  * If you are ''cleaning up white space, do it in a self-contained patch'' that contains no functional changes.
 * '''Run the [[WritingTests|test suite]]'''. Changes breaking the tests are usually integrated with the changes to fix the tests, so that the test suite will run clean in each revision. To test against main or crew, you can clone these repositories somewhere, run `make local` inside the repository, and then call the binary `hg` at the top level of the repository. In Unix you can make a symbolic link from somewhere in your path, such as a location in `/usr/local/bin` to this binary. For example:
 {{{
ln -s /usr/local/src/mercurial/crew/hg /usr/local/bin/hg-crew
}}}
 Then you can just invoke `hg-crew`.

Some other useful guidelines:

 * '''Don't feel discouraged if you're asked to do some changes.''' Even if you feel the requested changes are trivial, the developers could do it themselves or even they are a bit nitpicky, you're the one who can do them more effectively, and this way of working also optimizes the main developers' time.
 * '''Always resend the entire patch series,''' not just the changed patch, when you had to fix something in a patch series. To quote [[mpm]]: "In general, assume that I've forgotten everything about your earlier patch."
 * '''Don't hesitate to resend your patches or ask for review''' if no answer comes from the mailing list after a while... people may be busy and your changes may have been overlooked. Contributions are considered very valuable and you can be sure they deserve at least a response. Sometimes this response is just the act of committing your patch to one of the official repos. Scan the emails about new changesets that are sent to the devel list.
 * '''It may help to send patches to people directly in addition to the developers mailing list.''' Use `hg log` on the appropriate files to see who's been committing a lot to them. That gives you some guidance as to who to send patches to. People are in general more responsive when messages go straight to them instead of via a mailing list. It may also be helpful to have a look at the CategoryHomepage entries to find the relevant people to contact for a specific subsystem.
 * '''Joining the IRC channel''' (#mercurial on irc.freenode.net) can be an effective way to get ''faster review and valuable initial feedback''. Again, use `hg log` to see whom to chat up.
 * You could [[Serve|serve]] a repository over HTTP that contains the changes. With it, Matt only needs to [[Pull|pull]] from it if he likes the changes.
#pragma section-numbers 2
<<Include(A:dev)>>

= Contributing Changes =
How to help us improve Mercurial's code.

<<TableOfContents>>

== Submission checklist ==
Please double-check your patch meets the following guidelines (explained below) before submitting for review:

 1. first line of commit message is of the form "'''topic: uncapitalized, no trailing period'''"
 1. bugs that are resolved are mentioned in summary in the form "'''(issueNNNN)'''" (no space)
 1. patch [[OneChangePerPatch|does just one thing]] (if you need a bullet list, split your patch)
 1. patch contains no other gratuitous changes:
  * whitespace changes
  * code movement
  * typo fixes
  * string changes
 1. patch leaves Mercurial in a working state (doesn't depend on future patches)
 1. test suite has been updated and [[#Coding_style_and_testing|runs cleanly]] (use the [[Heptapod|Heptapod]] CI to make sure)
 1. code passes check-code and matches [[CodingStyle|coding style]]
 1. relevant help text is updated (see `mercurial/help/`)

If emailing:

 1. patches are sent to the mercurial-devel mailing list (not the [[Bugs|BTS]]) and are properly formatted (see below)
 1. appropriate branch is indicated in email subject (eg hg email --flag stable)
 1. version is indicated in email subject if this is an amended patch, (eg hg email --flag v2 if it has been amended once, or v3, v4, etc.)

== Getting started ==
Start by cloning a copy of Mercurial's main development repo:

{{{
hg clone https://foss.heptapod.net/mercurial/mercurial-devel
}}}
You'll also want to read the following pages:

 * MercurialApi
 * CodingStyle
 * CompatibilityRules
 * TimeBasedReleasePlan
 * OneChangePerPatch

Other pages you may find important:

 * LockingDesign
 * EncodingStrategy

== 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 [[HisteditExtension|histedit]] and [[EvolveExtension|the Evolve extension]] useful in this process.

Each patch in a series should:

 * implement one clear step in your process
 * leave the code in a working state (so bisect always works!)
 * include relevant test changes so they're independently testable
 * if emailing: be sent as a separate email

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

Things to consider:

 * put the least controversial pieces first - if you're lucky, they'll get applied right away
 * the difficulty of reviewing a patch increases rapidly with size - small patches are more likely to get attention
 * the probability of a patch getting rejected is also a function of its size - smaller patches mean fewer review round-trips
 * bigger patches have more bugs - smaller patches make it easier to locate regressions

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

 * [[Cmd:commit|commit --amend]] - modify a head commit's description and contents
 * [[RebaseExtension|rebase]] - move your commits from one part of history to another, combine commits
 * [[HisteditExtension|histedit]] - interactively rearrange and modify your commits
 * [[EvolveExtension|evolve]] - our vision for how history editing should work in the future (experimental)
 * [[MqExtension|mq]] - manage a stack of changes as patches

== 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!

 * See our [[CodingStyle|coding style]] for what we expect code to look like (yes, we're serious about the underscores)
 * Use ''`contrib/check-code.py`'' to check for common style errors ( {{{ python contrib/check-code.py --blame `/usr/bin/hg manifest` }}} )
 * Add new [[WritingTests#Be_careful_with_new_test_scripts.21|test cases as needed]]
 * [[WritingTests#Running_the_test_suite|Run the test suite]] to make sure you haven't broken anything
 * Patches should apply cleanly against the tip of the appropriate branch (default or stable)
 * '''Don't touch the i18n/''' directory for code or doc changes (translations is a [[TranslatingMercurial|separate process]])

== Example patch ==
Here is an example of a Mercurial patch with proper summary, description, coding style, and testing.

{{{
changeset: 21111:dda11e799529
branch: stable
user: FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date: Tue Mar 25 19:34:17 2014 +0900
files: mercurial/hg.py tests/test-clone.t
description:
hg: use "os.path.join()" to join path components which may be empty (issue4203)

Changset 2d0ab571b822 rewriting "hg.copystore()" with vfs uses
'dstbase + "/lock"' instead of "os.path.join()", because target files
given from "store.copyfiles()" already uses "/" as path separator

But in the repository using revlog format 0, "dstbase" becomes empty
("data" directory is located under ".hg" directly), and 'dstbase +
"/lock"' is treated as "/lock": in almost all cases, write access to
"/lock" causes "permission denied".

This patch uses "os.path.join()" to join path components which may be
empty in "hg.copystore()".


diff -r c57c9cece645 -r dda11e799529 mercurial/hg.py
--- a/mercurial/hg.py Mon Mar 24 21:27:40 2014 -0400
+++ b/mercurial/hg.py Tue Mar 25 19:34:17 2014 +0900
@@ -213,8 +213,10 @@
                 dstvfs.mkdir(dstbase)
             if srcvfs.exists(f):
                 if f.endswith('data'):
+ # 'dstbase' may be empty (e.g. revlog format 0)
+ lockfile = os.path.join(dstbase, "lock")
                     # lock to avoid premature writing to the target
- destlock = lock.lock(dstvfs, dstbase + "/lock")
+ destlock = lock.lock(dstvfs, lockfile)
                 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
                                              hardlink)
                 num += n
diff -r c57c9cece645 -r dda11e799529 tests/test-clone.t
--- a/tests/test-clone.t Mon Mar 24 21:27:40 2014 -0400
+++ b/tests/test-clone.t Tue Mar 25 19:34:17 2014 +0900
@@ -621,3 +621,17 @@
 #endif

   $ cd ..
+
+Test clone from the repository in (emulated) revlog format 0 (issue4203):
+
+ $ mkdir issue4203
+ $ mkdir -p src/.hg
+ $ echo foo > src/foo
+ $ hg -R src add src/foo
+ $ hg -R src commit -m '#0'
+ $ hg -R src log -q
+ 0:e1bab28bca43
+ $ hg clone -U -q src dst
+ $ hg -R dst log -q
+ 0:e1bab28bca43
+ $ cd ..
}}}
== Changing C code ==
Changes involving the C code should be done so that the tests will pass across changesets even without recompiling. This allows "bisect" to be run without needing to run "make" each time, for example.

A recommended strategy for changing behavior in the C code is to add a new interface to the C code when changing behavior (do not change old interfaces). Then in the Python code, check for the existence of the new interface.

If you change tests that rely on changes to C extensions, make sure you also run the tests in "pure" Python mode (and vice versa). For example:

{{{
$ python run-tests.py --pure
}}}
== 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
...
}}}
 * lowercase summary line, no trailing period
 * start with the most useful topic keyword (eg command name, subsystem), (the keywords mostly exist to sort our end-user release notes).
 * summarize the fix, not the problem
 * add '(issueNNNN)' if it fixes an issue in the BugTracker (and automatically move the issue to testing)
 * use '(BC)' to flag backward compatibility changes, use '(API)' to flag major internal API changes.
 * a blank line after the summary
 * a more complete description of the problem if necessary
 * all lines less than 80 characters

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:

 * why we need this patch
 * how you've implemented it
 * why the choices you've made are the right ones
 * why the choices you didn't make are the wrong ones
 * what all the corner cases are (consider a table!)
 * what shortcomings exist
 * what file formats and data structures you've used
 * what [[CompatibilityRules|compatibility issues]] exist
 * what's missing, if anything
 * what it looks like, if relevant ('''include sample output!''')

== Sending patches ==

/!\ Don't send your patch to the BugTracker - it can't be [[ManagingBugs#Dealing_with_patches_on_the_BTS|reviewed there]], so it won't go anywhere!

/!\ Sending a patch implies granting permission to use it in our project under an appropriate [[License|license]]

There are multiple options for sending patches to Mercurial. In order of preference:

 1. Heptapod. See [[Heptapod]] for usage instructions.
 1. email (see below)

If you have already multiple series waiting for review, sending any more patches is not advised. Please, please, please read the [[#Flow_control|Flow control]] section.

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. Find the patch submission on the [[MailingLists|mercurial-devel@mercurial-scm.org]] and reply to it, kindly requesting someone look at it. If it was submitted to Heptapod, you can leave a comment on Heptapod.

=== Emailing patches ===

The (heavily) recommended way of sending changes is through [[Heptapod]]. Email is kept as an option as a low-friction tool for small changes for drive-by contributors.

 * Patches go to [[MailingLists|mercurial-devel@mercurial-scm.org]] - '''no subscription necessary!''' (we manually whitelist all legitimate posters)
 * Patch emails should have '''[PATCH]''' in the subject followed by a summary (not included in the patch). New versions of the patch should be flagged with V2, V3 etc. so it becomes e.g. '''[PATCH V2]'''. See --flag option to hg email.
 * We prefer patches '''in the message body''' so we can review them (no attachments or URLs!)
 * Patches should be in the '`# HG changeset patch`' form output by '`hg export`' - unified diff with author and full patch description (see also the PatchbombExtension)
 * Apple Mail, Gmail and possibly other mail clients corrupt patches when sending them in the body, even when sending as plain text. Use the patchbomb extension, instead.

The best way to achieve well-formed patches is to use [[PatchbombExtension|patchbomb extension]] which automates the process. Add something like the following to your ''`.hgrc`'':

{{{
[extensions]
patchbomb=

[patchbomb]
confirm=True
intro=never

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

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

Run `hg help config.smtp` for more SMTP configuration options and `hg help email` and `hg help -e patchbomb` for more info on the `email` command and the extension that provides it.

Then run the following to do a dryrun test:

{{{
$ hg email --test <change1> <change2> ...
}}}
Notable options:

 * '`--flag`' can be used to flag a patch, e.g. "STABLE", "RFC", "v2"
 * don't use '`--inline`', it's a weird MIME thing and not what we want
 * '`--in-reply-to`' can be used to specify a message-id to preserve threading (helpful for followup patches).
 * Please '''do not''' send a 0 of X summary message. Those will be deleted in the inbox of code reviewers, and never be read. It's totally fine to discuss the history and purpose of a patch in a patch description. Future archaeologists will thank you.

== Flow control ==
Please try not to swamp the list with patches. We have more contributors than reviewers and we'd like to be sure everyone's patches get looked at.

Other advice:

 * Avoid sending more than 10 patches at once. If you have a big stack of patches for review, get them reviewed small group (around 6 patches) by small group. If your stack is very big you probably want to tell people on the list about it to figure out a way to get it reviewed. It's not uncommon for mechanical cleanups to get special attention from a dedicated reviewer.

 * Avoid having too many series in review at the same time. If you already have multiple series in review (even unrelated) sending more unrelated series is not going to help. Apply feedback you received on existing series to close them. Or do some review yourself to help people reviewing your patches. (see ReviewProcess)

== Etiquette and advice ==
 * Try to respond quickly to feedback before we forget what your patch is about
 * Tell us everything you want us to know about a patch, every time
 * If we ask for fixes, don't send a patch to your patch, send a new fixed patch
 * Consult '`hg log`' to cc: the most relevant developers for the code you're working on
 * Consider giving input on other people's patches
 * Discuss your patches on [[IRC]] to get faster review and valuable initial feedback

== See also ==
 * [[BasicCodingStyle|Basic coding style]]
 * Our [[CompatibilityRules|compatibility rules]] for new features
 * The [[PatchbombExtension|patchbomb extension]] automates emailing patches
 * The [[MQ]] extension is handy for managing patch series

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 submitting for review:

  1. first line of commit message is of the form "topic: uncapitalized, no trailing period"

  2. bugs that are resolved are mentioned in summary in the form "(issueNNNN)" (no space)

  3. patch does just one thing (if you need a bullet list, split your patch)

  4. patch contains no other gratuitous changes:
    • whitespace changes
    • code movement
    • typo fixes
    • string changes
  5. patch leaves Mercurial in a working state (doesn't depend on future patches)
  6. test suite has been updated and runs cleanly (use the Heptapod CI to make sure)

  7. code passes check-code and matches coding style

  8. relevant help text is updated (see mercurial/help/)

If emailing:

  1. patches are sent to the mercurial-devel mailing list (not the BTS) and are properly formatted (see below)

  2. appropriate branch is indicated in email subject (eg hg email --flag stable)
  3. version is indicated in email subject if this is an amended patch, (eg hg email --flag v2 if it has been amended once, or v3, v4, etc.)

2. Getting started

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

hg clone https://foss.heptapod.net/mercurial/mercurial-devel

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 histedit and the Evolve extension useful in this process.

Each patch in a series should:

  • implement one clear step in your process
  • leave the code in a working state (so bisect always works!)
  • include relevant test changes so they're independently testable
  • if emailing: be sent as a separate email

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

Things to consider:

  • put the least controversial pieces first - if you're lucky, they'll get applied right away
  • the difficulty of reviewing a patch increases rapidly with size - small patches are more likely to get attention
  • the probability of a patch getting rejected is also a function of its size - smaller patches mean fewer review round-trips
  • bigger patches have more bugs - smaller patches make it easier to locate regressions

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:

  • commit --amend - modify a head commit's description and contents

  • rebase - move your commits from one part of history to another, combine commits

  • histedit - interactively rearrange and modify your commits

  • evolve - our vision for how history editing should work in the future (experimental)

  • mq - manage a stack of changes as patches

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!

  • See our coding style for what we expect code to look like (yes, we're serious about the underscores)

  • Use contrib/check-code.py to check for common style errors (  python contrib/check-code.py --blame `/usr/bin/hg manifest`  )

  • Add new test cases as needed

  • Run the test suite to make sure you haven't broken anything

  • Patches should apply cleanly against the tip of the appropriate branch (default or stable)
  • Don't touch the i18n/ directory for code or doc changes (translations is a separate process)

5. Example patch

Here is an example of a Mercurial patch with proper summary, description, coding style, and testing.

changeset:   21111:dda11e799529
branch:      stable
user:        FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date:        Tue Mar 25 19:34:17 2014 +0900
files:       mercurial/hg.py tests/test-clone.t
description:
hg: use "os.path.join()" to join path components which may be empty (issue4203)

Changset 2d0ab571b822 rewriting "hg.copystore()" with vfs uses
'dstbase + "/lock"' instead of "os.path.join()", because target files
given from "store.copyfiles()" already uses "/" as path separator

But in the repository using revlog format 0, "dstbase" becomes empty
("data" directory is located under ".hg" directly), and 'dstbase +
"/lock"' is treated as "/lock": in almost all cases, write access to
"/lock" causes "permission denied".

This patch uses "os.path.join()" to join path components which may be
empty in "hg.copystore()".


diff -r c57c9cece645 -r dda11e799529 mercurial/hg.py
--- a/mercurial/hg.py   Mon Mar 24 21:27:40 2014 -0400
+++ b/mercurial/hg.py   Tue Mar 25 19:34:17 2014 +0900
@@ -213,8 +213,10 @@
                 dstvfs.mkdir(dstbase)
             if srcvfs.exists(f):
                 if f.endswith('data'):
+                    # 'dstbase' may be empty (e.g. revlog format 0)
+                    lockfile = os.path.join(dstbase, "lock")
                     # lock to avoid premature writing to the target
-                    destlock = lock.lock(dstvfs, dstbase + "/lock")
+                    destlock = lock.lock(dstvfs, lockfile)
                 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
                                              hardlink)
                 num += n
diff -r c57c9cece645 -r dda11e799529 tests/test-clone.t
--- a/tests/test-clone.t        Mon Mar 24 21:27:40 2014 -0400
+++ b/tests/test-clone.t        Tue Mar 25 19:34:17 2014 +0900
@@ -621,3 +621,17 @@
 #endif

   $ cd ..
+
+Test clone from the repository in (emulated) revlog format 0 (issue4203):
+
+  $ mkdir issue4203
+  $ mkdir -p src/.hg
+  $ echo foo > src/foo
+  $ hg -R src add src/foo
+  $ hg -R src commit -m '#0'
+  $ hg -R src log -q
+  0:e1bab28bca43
+  $ hg clone -U -q src dst
+  $ hg -R dst log -q
+  0:e1bab28bca43
+  $ cd ..

6. Changing C code

Changes involving the C code should be done so that the tests will pass across changesets even without recompiling. This allows "bisect" to be run without needing to run "make" each time, for example.

A recommended strategy for changing behavior in the C code is to add a new interface to the C code when changing behavior (do not change old interfaces). Then in the Python code, check for the existence of the new interface.

If you change tests that rely on changes to C extensions, make sure you also run the tests in "pure" Python mode (and vice versa). For example:

$ python run-tests.py --pure

7. 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
...
  • lowercase summary line, no trailing period
  • start with the most useful topic keyword (eg command name, subsystem), (the keywords mostly exist to sort our end-user release notes).
  • summarize the fix, not the problem
  • add '(issueNNNN)' if it fixes an issue in the BugTracker (and automatically move the issue to testing)

  • use '(BC)' to flag backward compatibility changes, use '(API)' to flag major internal API changes.
  • a blank line after the summary
  • a more complete description of the problem if necessary
  • all lines less than 80 characters

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:

  • why we need this patch
  • how you've implemented it
  • why the choices you've made are the right ones
  • why the choices you didn't make are the wrong ones
  • what all the corner cases are (consider a table!)
  • what shortcomings exist
  • what file formats and data structures you've used
  • what compatibility issues exist

  • what's missing, if anything
  • what it looks like, if relevant (include sample output!)

8. Sending patches

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

/!\ Sending a patch implies granting permission to use it in our project under an appropriate license

There are multiple options for sending patches to Mercurial. In order of preference:

  1. Heptapod. See Heptapod for usage instructions.

  2. email (see below)

If you have already multiple series waiting for review, sending any more patches is not advised. Please, please, please read the Flow control section.

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. Find the patch submission on the mercurial-devel@mercurial-scm.org and reply to it, kindly requesting someone look at it. If it was submitted to Heptapod, you can leave a comment on Heptapod.

8.1. Emailing patches

The (heavily) recommended way of sending changes is through Heptapod. Email is kept as an option as a low-friction tool for small changes for drive-by contributors.

  • Patches go to mercurial-devel@mercurial-scm.org - no subscription necessary! (we manually whitelist all legitimate posters)

  • Patch emails should have [PATCH] in the subject followed by a summary (not included in the patch). New versions of the patch should be flagged with V2, V3 etc. so it becomes e.g. [PATCH V2]. See --flag option to hg email.

  • We prefer patches in the message body so we can review them (no attachments or URLs!)

  • Patches should be in the '# HG changeset patch' form output by 'hg export' - unified diff with author and full patch description (see also the PatchbombExtension)

  • Apple Mail, Gmail and possibly other mail clients corrupt patches when sending them in the body, even when sending as plain text. Use the patchbomb extension, instead.

The best way to achieve well-formed patches is to use patchbomb extension which automates the process. Add something like the following to your .hgrc:

[extensions]
patchbomb=

[patchbomb]
confirm=True
intro=never

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

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

Run hg help config.smtp for more SMTP configuration options and hg help email and hg help -e patchbomb for more info on the email command and the extension that provides it.

Then run the following to do a dryrun test:

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

Notable options:

  • '--flag' can be used to flag a patch, e.g. "STABLE", "RFC", "v2"

  • don't use '--inline', it's a weird MIME thing and not what we want

  • '--in-reply-to' can be used to specify a message-id to preserve threading (helpful for followup patches).

  • Please do not send a 0 of X summary message. Those will be deleted in the inbox of code reviewers, and never be read. It's totally fine to discuss the history and purpose of a patch in a patch description. Future archaeologists will thank you.

9. Flow control

Please try not to swamp the list with patches. We have more contributors than reviewers and we'd like to be sure everyone's patches get looked at.

Other advice:

  • Avoid sending more than 10 patches at once. If you have a big stack of patches for review, get them reviewed small group (around 6 patches) by small group. If your stack is very big you probably want to tell people on the list about it to figure out a way to get it reviewed. It's not uncommon for mechanical cleanups to get special attention from a dedicated reviewer.
  • Avoid having too many series in review at the same time. If you already have multiple series in review (even unrelated) sending more unrelated series is not going to help. Apply feedback you received on existing series to close them. Or do some review yourself to help people reviewing your patches. (see ReviewProcess)

10. Etiquette and advice

  • Try to respond quickly to feedback before we forget what your patch is about
  • Tell us everything you want us to know about a patch, every time
  • If we ask for fixes, don't send a patch to your patch, send a new fixed patch
  • Consult 'hg log' to cc: the most relevant developers for the code you're working on

  • Consider giving input on other people's patches
  • Discuss your patches on IRC to get faster review and valuable initial feedback

11. See also


CategoryDeveloper

ContributingChanges (last edited 2023-04-06 07:59:14 by RaphaelGomes)