bzr-feed HOWTO

January 2, 2008

bzr-feed is a Python script written by Morten Frederiksen which generates Atom feeds from Bazaar repositories. Users and other developers can subscribe to the feed and receive notifications of new revisions automatically.

Obtaining bzr-feed

You can obtain the bzr-feed source code from one of the following locations by downloading a tarball or zip file, browsing the source code, or by installing Bazaar and creating your own branch. Each of these branches also has a feed. The best way to track bzr-feed development is by subscribing to the global bzr-feed feed

Running bzr-feed as a CGI script

The basics

The basic approach to generating feeds dynamically is to place the bzr-feed.py script somewhere on the site, say http://foo.com/bzr-feed.cgi and link to the feed as follows:

http://foo.com/bzr-feed.cgi?dir=bar

Of course, your web server must have Python installed and you must have permission to run CGI scripts.

Using mod_rewrite

If mod_rewrite is available, one can make the URLs look nicer by creating an appropriate rewrite rule in .htaccess. Here are a few examples.

This rule is a generalization of the single project rule using regular expressions. It says that if the request filename is of the form http://foo.com/path/bar.atom (line 2) and the file does not exist on the server (line 1), then run bzr-feed.cgi?dir=path/to/project and return the contents.

Running bzr-feed locally

You can also run bzr-feed locally to generate the Atom feed and then copy it to a web server. You may want to do this if your hosting provider does not have bzr installed or you don’t have permission to run CGI scripts. Following Sam Ruby, you can accomplish this by setting the appropriate environment variables in a shell script.

export HTTP_HOST=foo.com
export SERVER_PORT=80
export REQUEST_URI=/bar/index.atom
python /path/to/bzr-feed.py dir=bar > bar/index.atom

Using shared repositories

bzr-feed also works with shared repositories. Suppose there is a shared repository at http://foo.com/bar with the following layout:

bar
|-- branch1
`-- branch2

bzr-feed can generate feeds for both branches:

http://foo.com/bzr-feed.cgi?dir=bar&branch=branch1
http://foo.com/bzr-feed.cgi?dir=bar&branch=branch2

To do this locally, write a script like this:

export HTTP_HOST=foo.com
export SERVER_PORT=80
export REQUEST_URI="/bar/branch1/index.atom"
python /path/bzr-feed.py dir=bar\&branch=branch1 > bar/branch1/index.atom