~bzr-pqm/bzr/bzr.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
==============
Bazaar plugins
==============

Information on how to use plugins in Bazaar.

What is a Plugin
================
A plugin is an external component for Bazaar that is typically made by
third parties. A plugin is capable of augmenting Bazaar by adding new
functionality.  A plugin can also change current Bazaar behavior by
replacing current functionality. Plugins often work as a way for
developers to test new features for Bazaar prior to inclusion in the
official codebase. Plugins can do a variety of things, including
overriding commands, adding new commands, providing additional network
transports, or customizing log output. The sky is the limit for the
customization that can be done through plugins.

Where to find Plugins 
=====================
We keep our list of plugins on the http://bazaar-vcs.org/BzrPlugins page.

Writing a plugin
================
Plugins are very similar to bzr core functionality.  They can import
anything in bzrlib.  A plugin may simply override standard functionality,
but most plugins supply new commands.

To create a command, make a new object that derives from
``bzrlib.commands.Command``, and name it ``cmd_foo``, where foo is the name of
your command.  If you create a command whose name contains an underscore,
it will appear in the UI with the underscore turned into a hyphen.  For
example, `cmd_baz_import` will appear as `baz-import`.  For examples of how
to write commands, please see ``builtins.py``.

Once you've created a command you must register the command with
``bzrlib.commands.register_command(cmd_foo)``.  You must register the
command when your file is imported, otherwise bzr will not see it.

Bzr will scan ``bzrlib/plugins`` and ``~/.bazaar/plugins`` for plugins
by default.  You can override this with ``BZR_PLUGIN_PATH``.  Plugins
may be either modules or packages.  If your plugin is a single file,
you can structure it as a module.  If it has multiple files, or if you
want to distribute it as a bzr branch, you should structure it as a
package, i.e. a directory with an ``__init__.py`` file.

Please feel free to contribute your plugin to BzrTools, if you think it
would be useful to other people.

How to Install a plugin 
=======================
Installing a plugin is very easy! One can either install a plugin
system-wide or on a per user basis. Both methods involve creating a
``plugins`` directory. Within this directory one can place plugins in
subdirectories. For example, ``plugins/bzrtools/``.

Two locations are currently checked:  the bzrlib/plugins directory
(typically found in ``/usr/lib/python2.4/site-packages/bzrlib/plugins/``) and
``$HOME/.bazaar/plugins/``.

One can additionally override the home plugins by setting the environment
variable ``BZR_PLUGIN_PATH`` to a directory that contains plugins. The
installation of a plugin can be checked by running ``bzr plugins`` at
any time. New commands can be seen by running ``bzr help commands``.

Plugins work particularly well with Bazaar branches. For example, to
install the bzrtools plugins for your main user account, one can perform
the following:: 

    bzr branch http://panoramicfeedback.com/opensource/bzr/bzrtools
    ~/.bazaar/plugins/bzrtools