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 script somewhere on the site, say and link to the feed as follows:

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 (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 SERVER_PORT=80
export REQUEST_URI=/bar/index.atom
python /path/to/ dir=bar > bar/index.atom

Using shared repositories

bzr-feed also works with shared repositories. Suppose there is a shared repository at with the following layout:

|-- branch1
`-- branch2

bzr-feed can generate feeds for both branches:

To do this locally, write a script like this:

export SERVER_PORT=80
export REQUEST_URI="/bar/branch1/index.atom"
python /path/ dir=bar\&branch=branch1 > bar/branch1/index.atom