~bzr-pqm/bzr/bzr.dev

1861.2.6 by Alexander Belchenko
branding: change Bazaar-NG to Bazaar
1
==============
2
Bazaar plugins
3
==============
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
4
1861.2.6 by Alexander Belchenko
branding: change Bazaar-NG to Bazaar
5
Information on how to use plugins in Bazaar.
1821.1.1 by Alexander Belchenko
win32 installer for bzr.dev.0.9
6
1610.2.1 by James Blackwell
Copied in docs for wiki & First round cleanup
7
What is a Plugin
8
================
1861.2.6 by Alexander Belchenko
branding: change Bazaar-NG to Bazaar
9
A plugin is an external component for Bazaar that is typically made by
10
third parties. A plugin is capable of augmenting Bazaar by adding or
11
replacing new or current functionality in Bazaar. Plugins often work as
12
a way for developers to test new features for Bazaar prior to inclusion
1610.2.1 by James Blackwell
Copied in docs for wiki & First round cleanup
13
in the official codebase. Plugins can do a variety of things, including
14
overriding commands, adding new commands, providing additional network
15
transports, customizing log output. The sky is the limit for the
16
customization that can be done through plugins.
17
18
Where to find Plugins 
19
=====================
20
We keep our list of plugins on the http://bazaar-vcs.org/PluginRegistry page.
21
22
Writing a plugin
23
================
24
Plugins are very similar to bzr core functionality.  They can import
25
anything in bzrlib.  A plugin may simply override standard functionality,
26
but most plugins supply new commands.
27
28
To create a command, make a new object that derives from
29
`bzrlib.commands.Command`, and name it cmd_foo, where foo is the name of
30
your command.  If you create a command whose name contains an underscore,
31
it will appear in the UI with the underscore turned into a hyphen.  For
32
example, "cmd_baz_import" will appear as "baz-import".  For examples of how
33
to write commands, please see builtins.py.
34
35
Once you've created a command you must register the command with
36
`bzrlib.commands.register_command(cmd_foo)`.  You must register the command
37
when your file is imported, otherwise bzr will not see it.
38
1610.2.2 by James Blackwell
Now they look good in rst2html
39
Bzr will scan **bzrlib/plugins** and **~/.bazaar/plugins** for plugins by
40
default.  You can override this with **BZR_PLUGIN_PATH**.  Plugins may be
1610.2.1 by James Blackwell
Copied in docs for wiki & First round cleanup
41
either modules or packages.  If your plugin is a single file, you can
42
structure it as a module.  If it has multiple files, or if you want to
43
distribute it as a bzr branch, you should structure it as a package, i.e. a
1610.2.2 by James Blackwell
Now they look good in rst2html
44
directory with an **__init__.py** file.
1610.2.1 by James Blackwell
Copied in docs for wiki & First round cleanup
45
46
Please feel free to contribute your plugin to BzrTools, if you think it
47
would be useful to other people.
48
49
How to Install a plugin 
50
=======================
51
Installing a plugin is very easy! One can either install a plugin
52
systemwide or on a user by user basis. Both methods involve create a
53
"plugins" directory. Within this directory one can place plugins in
54
subdirectories. For example, "plugins/bzrtools/".
55
56
Two locations are currently checked; the bzrlib/plugins directory
57
(typically found in /usr/lib/python2.4/site-packages/bzrlib/plugins/) and
58
$HOME/.bazaar/plugins/.
59
60
One can additionally override the home plugins by setting the environment
61
variable BZR_PLUGIN_PATH to a directory that contains plugins. The
62
installation of a plugin can be checked by running **bzr plugins** at
63
any time. New commands can be seen by running **bzr help commands**.
64
1861.2.6 by Alexander Belchenko
branding: change Bazaar-NG to Bazaar
65
Plugins work particularly well with Bazaar branches. For example, to
1610.2.1 by James Blackwell
Copied in docs for wiki & First round cleanup
66
install the bzrtools plugins for your main user account, one can perform
67
the following:: 
68
69
    bzr branch http://panoramicfeedback.com/opensource/bzr/bzrtools
70
    ~/.bazaar/plugins/bzrtools
71