Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Python library and command-line tools for interacting with Bugzilla via Gervase Markham's REST API.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .hgignore
Octocat-spinner-32 README.md
Octocat-spinner-32 bugzilla.py
Octocat-spinner-32 bzpatch.py
Octocat-spinner-32 minimock.py
Octocat-spinner-32 test_bugzilla.py
README.md

Installation

First, run the unit tests to make sure everything works okay:

python test_bugzilla.py

Then make a symlink to bzpatch, the command-line tool:

ln -s bzpatch.py ~/bin/bzpatch

Now create a file called ~/.bugzilla-config.json and fill it out with something like this:

{
  "username": "me@email.com"
, "password": "foo"
}

If you really don't like the idea of leaving your Bugzilla password in a plaintext file on your computer, you can leave out the password key and you'll just be prompted for your password every time you use bzpatch. You might also want to contact the Bugzilla team and ask them to implement OAuth or something to make this process both convenient and secure.

Usage

You can run bzpatch without any command-line options to get a bit of help.

Posting or applying a patch

Assuming you're in a Mercurial repository and have made some changes to it, you can pipe hg diff output into bzpatch post like so:

hg diff | bzpatch post 12345 "first patch attempt"

This posts the diff as a patch attachment to bug 12345 with the name/description "first patch attempt". The patch also contains HG-specific headers that provide information about the author, bug number, and bug summary.

To request review, pass in the name or email address of the requestee:

hg diff | bzpatch post 12345 "first patch attempt" :atul
hg diff | bzpatch post 12345 "first patch attempt" avarma@mozilla.com

Note that bzpatch post doesn't automatically obsolete any earlier patches.

You can apply the above patch by piping the output of bzpatch get:

bzpatch get 12345 | hg import -

Note that once the patch is imported, the changeset author is already set to your Bugzilla username/email, and the changeset description contains the name and number of the bug, thanks to the HG-specific headers that were in the patch file.

Note that bzpatch get automatically retrieves the most recently-uploaded patch, if multiple ones are found.

Posting a pointer to a GitHub pull request

Some Mozilla projects are starting to use GitHub with Bugzilla, and pull requests are much easier to deal with than patches. One way to deal effectively with this hybrid development process is to upload an attachment to a bug that is simply a "pointer" to a GitHub pull request. For an example of this, see bug 610816.

To automatically post such a request, you can do this:

bzpatch pullreq 610816 https://github.com/mozilla/addon-sdk/pull/49

To request review, pass in the name or email address of the requestee:

bzpatch pullreq 610816 https://github.com/mozilla/addon-sdk/pull/49 :atul
bzpatch pullreq 610816 https://github.com/mozilla/addon-sdk/pull/49 avarma@mozilla.com

Note that, like bzpatch post, this command doesn't automatically obsoletes older attachments.

Something went wrong with that request. Please try again.