Bugzilla:Committing Patches

From MozillaWiki
Revision as of 11:51, 23 July 2010 by MaxKanatAlexander (talk | contribs) ("add" on multiple branches should use --file-ids-from, to make life a little easier for mergers)
Jump to navigation Jump to search

Note: In order to commit you must have bzr 1.17 or later. 2.0 or later is ideal, as it will be faster.

Here's how to commit a patch:

  1. Become a Mozilla Committer. For Bugzilla, the requirement is that one of the Assistant Project Leads or the Project Lead vouch for you. Your bug should be filed in the Account Request: Hg component, because there is no Bzr component. (Note: If you are already a Mozilla Committer and you just need Bzr access, just file a bug in this component requesting it and CC one of the Bugzilla leads.)
  2. If you have never told bzr your name and email address, you have to use "bzr whoami" to do this:
    bzr whoami 'Max Kanat-Alexander <mkanat@bugzilla.org>'
    (Of course, you would replace that name and email address with your own.) The email address that you use must be identical to your login name for bzr.mozilla.org.

    Please include both your full name and your email address in the "whoami", because your full name is what is displayed in the web view of the repository.
  3. Configure bzr to know about bugzilla.mozilla.org as a bug-tracker (this will be important when you get to the actual commit step). To do this, edit the .bazaar/bazaar.conf file in your home directory and add this line at the end:
    bugzilla_mozilla_url = https://bugzilla.mozilla.org
    (If you're on Windows, this file is in C:\Documents and Settings\<username>\Application Data\Bazaar\2.0 instead of in $HOME/.bazaar.)
  4. Get a checkout of Bugzilla using bzr+ssh:// (not just bzr://):
    bzr co bzr+ssh://username@domain.com@bzr.mozilla.org/bugzilla/trunk bugzilla
    Note: If you want to avoid including your username every time you do a checkout over bzr+ssh, you can edit $HOME/.ssh/config and add the following lines:

    Host bzr.mozilla.org
        User username@domain.com
  5. Apply the patch you'll be committing:
    cd bugzilla; patch -p0 < patchfile
    (Or, if it's a bundle, see the instructions on applying bundles.)
  6. Run "bzr add" to add any files that should be added:
    bzr add
    If you add the same file on multiple branches, make sure to use the argument --file-ids-from=/path/to/trunk-checkout for all adds that aren't on the trunk.
  7. Check that everything is as it should be:
    bzr status
  8. Commit the patch:
    bzr commit --fixes mozilla:123456 --author='Somebody Else <somebody@example.com>'
    That number after --fixes is the bug id that the patch fixes. You should specify this with every commit. --author is used only when you are committing somebody else's patch. It lets bzr know who the actual author of the patch is.

    It's very important to remember --fixes and (if necessary) --author--they cannot be set after you have committed, only while you are committing.
  9. This will bring up an editor window, using whatever your EDITOR environment variable is set to in your shell. The following instructions assume you use vi, which is the default on many systems. If you use some other editor, refer to the documentation for your editor.

    To start typing in the vi window, press the "i" key on your keyboard. Then you should enter a checkin comment that looks like this:

    Bug 123456: What The Patch Does Goes Here
    r=mkanat, a=justdave


    Just replace everything in italics with the right thing. r= indicates the person(s) who reviewed your patch. a= indicates the person who approved it for checkin.

    Note that the description given on the checkin comment should describe what the patch actually does (in a broad sense), which may not necessarily match the summary of the bug being fixed. For example, of the summary of the bug is "Bugzilla doesn't do Foo" then your description in the checkin comment should say something like "Make Bugzilla do Foo". If the first line is longer than 80 characters, manually word-wrap it on to multiple lines.

    To close vi, save the message, and commit your changes, press ESC and then type :wq on the keyboard, and press Enter. If you want to quit without committing (say, you made a mistake and you want to go back), instead of :wq you type :q! (with the exclamation point).
  10. bzr will print out a commit message. Make sure you copy this so you can add it as a comment on the bug when you mark the bug FIXED. Include everything from (and including) the "Committing to:" through the "Committed revision 1234." line.
  11. Paste the bzr commit message as a comment on the bug and mark it FIXED.