From MozillaWiki
Jump to: navigation, search

Commit Message Restrictions

The purpose of these new restrictions, implemented via a mercurial hook, is to prevent commit messages that do not have a bug number. We will still allow a small set of special commits lacking bugs numbers, like merges and backouts.

This hook will be enabled on mozilla-central and every major branch that directly merges into it, such as mozilla-inbound or integration branches, team branches, or established project branches.

An example for a passing commit message would be,

Bug 577872 - Create WebM versions of Ogg reftests. r=kinetik

notice the Bug ##### and the r= indicating the reviewer. Also the reviewer is not checked at the moment, it could be at a future time and you are strongly encouraged to include it. (Please no fake reviewers like "my-dog" or "burning"). You also can't commit bustage-fixes without a bug number anymore. This is intentional to keep track of the bug which caused it.

Allowed are:

  • Commit messages containing "bug" or "b=" followed by a bug number
  • Commit messages containing "no bug" (please use this sparingly)
  • Commit message indicating backout of a given 12+ digit changeset ID, starting with (back out|backing out|backed out|backout)( of)? (rev|changeset|cset)s? [0-9a-f]{12}
  • Commit messages that start with "merge" or "merging" and are actually for a merge changeset.

Special exceptions:

  • Updating the NanoJit import in the js/src tree ("Update nanojit-import-rev stamp.")
  • Commits by the special users "ffxbld", "seabld", "tbirdbld", or "cltbld".
  • When the commit is older then some date shortly after the hook has been enabled, to allow merges from other branches. This exception will be lifted after a short period of time (probably a few months) after the hooks is enabled.
  • You can also specify "ALLOW BAD COMMIT MESSAGES" in the tip (latest) commit message to override all the restrictions. This is an extreme measure, so you should only do this if you have a very good reason.

Explicitly disallowed:

  • Commit messages containing "try: " to avoid unintentional commits that were meant for the try server.

All tests for allowed or excluded messages are case case-insensitive.

You can find the source code of this hook at

Local setup

It is also possible to use this hook locally so you can see if there is something wrong with your commit messages before pushing.

Change your .hgrc to include:

pretxncommit.commit = python:commit-message.hook

You probably need to add to your Python path.

export PYTHONPATH = ~/myhooks # assuming is in this folder

You can also edit to abort commits instead of warning. Search for "to fail not warn change to 1" (without the quotes) in the the file and change 0 to 1.