Integrating Bazaar into Trac

Trac is a web application that integrates repository browsing, bug tracker, and wiki. Support for Bazaar repositories can be enabled in Trac by installing the Trac Bazaar plugin (also known as trac+bzr).

Configuring Trac is beyond the scope of this book; here, we assume that you already have a working Trac installation and focus on how to enable Bazaar support for it.

Enabling the plugin globally

The best way to install Trac is by using your operating system's package manager. Look for a package named tracbzr. Alternatively, you can install it by using Pip, the Python package manager, or from source.

$ pip install tracbzr bzr==2.5

The Bazaar libraries are a runtime dependency of the plugin, that's why we need to install bzr too. We specified an explicit version of bzr, because by default Pip installs the latest unstable version of bzr, which might not always work well.

Another important point is to use the same Python version as the one Trac is running with. For example, if you are normally using Python 2.7, but Trac is running with Python 2.6, then in the preceding command you should use pip-2.6 instead. You can confirm the Python version used by pip by using the command pip --version.

After the plugin is installed, enable it in the trac.ini file of the Trac project's environment by editing or adding a components section as follows:

[components]
tracbzr.* = enabled

Finally, add your Bazaar branch locations by using the trac-admin command of Trac:

$ trac-admin ENV repository add NICK PATH bzr

Here:

  • ENV is the path to the Trac project environment
  • NICK is a short name to identify the location in Trac
  • PATH is the path to a directory; it can be a branch, a shared repository, or just a plain directory

The bzr parameter at the end of the command is to indicate that this is a Bazaar repository, so that Trac knows the right plugin to use when working with it.

To remove repository locations from Trac, use the remove command:

$ trac-admin ENV repository remove NICK

After adding or removing locations, you may need to resync Trac's database:

$ trac-admin ENV repository resync NICK

You can resync all locations at once by using the following command:

$ trac-admin ENV repository resync '*'

Enabling the plugin for one project only

If you don't want to install the tracbzr Python module system-wide, then another option is to package the module as an egg file and drop it into the plugins directory in the project environment.

You may be able to get an egg file from the Launchpad page of the Python module:

https://launchpad.net/trac-bzr

Look for the Downloads section at the right-hand side; there are usually several egg packages corresponding to different Python versions.

If there is no download file for your version of Python, or if you prefer to build the package yourself, that's easy enough to do. In this case, download the tarball and build the package with the bdist_egg command as follows:

$ tar zxf TracBzr-0.4.2.tar.gz
$ cd TracBzr-0.4.2/
$ python setup.py bdist_egg
$ ls dist/
TracBzr-0.4.2-py2.7.egg

This creates the egg package inside the dist/ directory. Copy the package to the plugins directory of your Trac project environment and restart Trac.

Browsing Bazaar branches

If the Bazaar plugin has been successfully configured, then the Browse Source tab should be visible, and you should be able to browse the directory tree of Bazaar branches:

Browsing Bazaar branches

You can browse the contents of versioned files and directories and see other details such as the following:

  • View the files and directories at a specific revision
  • View the differences between any two revisions
  • View each line of a file annotated with the revision information that changed it
  • View the list of revisions that changed a file
  • View the log of revisions in a branch

Beware that there are some limitations of the plugin, as documented in the Limitations section of the plugin's homepage:

http://pypi.python.org/pypi/TracBzr

Getting help

For more details, see the plugin's Launchpad page:

https://launchpad.net/trac-bzr

Or the plugin's project homepage:

http://pypi.python.org/pypi/TracBzr

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.178.237