~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/plugins.txt

  • Committer: Robert Collins
  • Date: 2007-07-19 06:34:09 UTC
  • mto: (2592.3.46 repository)
  • mto: This revision was merged to the branch mainline in revision 2651.
  • Revision ID: robertc@robertcollins.net-20070719063409-stu9sckrxp8wp3mo
LIBRARY API BREAKS:

  * KnitIndex.get_parents now returns tuples. (Robert Collins)

INTERNALS:

  * Unused functions on the private interface KnitIndex have been removed.
    (Robert Collins)

  * New ``knit.KnitGraphIndex`` which provides a ``KnitIndex`` layered on top
    of a ``index.GraphIndex``. (Robert Collins)

  * New ``knit.KnitVersionedFile.iter_parents`` method that allows querying
    the parents of many knit nodes at once, reducing round trips to the 
    underlying index. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Using plugins
2
 
=============
3
 
 
4
 
.. Information on how to use plugins in Bazaar.
5
 
 
6
 
What is a plugin?
7
 
-----------------
8
 
 
 
1
==============
 
2
Bazaar plugins
 
3
==============
 
4
 
 
5
Information on how to use plugins in Bazaar.
 
6
 
 
7
What is a Plugin
 
8
================
9
9
A plugin is an external component for Bazaar that is typically made by
10
10
third parties. A plugin is capable of augmenting Bazaar by adding new
11
11
functionality.  A plugin can also change current Bazaar behavior by
12
 
replacing current functionality. Sample applications of plugins are:
13
 
 
14
 
* overriding commands
15
 
* adding new commands
16
 
* providing additional network transports
17
 
* customizing log output.
18
 
  
19
 
The sky is the limit for the customization that can be done through plugins.
20
 
In fact, plugins often work as a way for developers to test new features for
21
 
Bazaar prior to inclusion in the official codebase. Plugins are helpful
22
 
at feature retirement time as well, e.g. deprecated file formats may one
23
 
day be removed from the Bazaar core and be made available as a plugin instead.
24
 
 
25
 
Plugins are good for users, good for external developers and good for
26
 
Bazaar itself.
27
 
 
28
 
Where to find plugins 
29
 
---------------------
30
 
 
 
12
replacing current functionality. Plugins often work as a way for
 
13
developers to test new features for Bazaar prior to inclusion in the
 
14
official codebase. Plugins can do a variety of things, including
 
15
overriding commands, adding new commands, providing additional network
 
16
transports, or customizing log output. The sky is the limit for the
 
17
customization that can be done through plugins.
 
18
 
 
19
Where to find Plugins 
 
20
=====================
31
21
We keep our list of plugins on the http://bazaar-vcs.org/BzrPlugins page.
32
22
 
33
 
How to install a plugin 
34
 
-----------------------
35
 
 
36
 
Installing a plugin is very easy! If not already created, create a
37
 
``plugins`` directory under your Bazaar configuration directory,
38
 
``~/.bazaar/`` on Linux and
39
 
``C:\Documents and Settings\<username>\Application Data\Bazaar\2.0\``
40
 
on Windows. Within this directory (referred to as $BZR_HOME below),
41
 
each plugin is placed in its own subdirectory.
 
23
How to Install a plugin 
 
24
=======================
 
25
Installing a plugin is very easy! One can either install a plugin
 
26
system-wide or on a per user basis. Both methods involve creating a
 
27
``plugins`` directory. Within this directory one can place plugins in
 
28
subdirectories. For example, ``plugins/bzrtools/``.
 
29
 
 
30
Two locations are currently checked:  the bzrlib/plugins directory
 
31
(typically found in ``/usr/lib/python2.4/site-packages/bzrlib/plugins/``) and
 
32
``$HOME/.bazaar/plugins/``.
 
33
 
 
34
One can additionally override the home plugins by setting the environment
 
35
variable ``BZR_PLUGIN_PATH`` to a directory that contains plugins. The
 
36
installation of a plugin can be checked by running ``bzr plugins`` at
 
37
any time. New commands can be seen by running ``bzr help commands``.
 
38
The commands provided by a plugin are shown followed by the name of the
 
39
plugin in brackets.
42
40
 
43
41
Plugins work particularly well with Bazaar branches. For example, to
44
 
install the bzrtools plugins for your main user account on Linux,
45
 
one can perform the following:: 
 
42
install the bzrtools plugins for your main user account, one can perform
 
43
the following:: 
46
44
 
47
45
    bzr branch http://panoramicfeedback.com/opensource/bzr/bzrtools
48
46
    ~/.bazaar/plugins/bzrtools
49
47
 
50
 
When installing plugins, the directories that you install them in must
 
48
When installing plugins the directories that you install them in must
51
49
be valid python identifiers. This means that they can only contain
52
50
certain characters, notably they cannot contain hyphens (``-``). Rather
53
 
than installing ``bzr-gtk`` to ``$BZR_HOME/plugins/bzr-gtk``, install it
54
 
to ``$BZR_HOME/plugins/gtk``.
55
 
 
56
 
Alternative plugin locations
57
 
----------------------------
58
 
 
59
 
If you have the necessary permissions, plugins can also be installed on
60
 
a system-wide basis. Two locations are currently checked for plugins:
61
 
 
62
 
 1. the system location - bzrlib/plugins
63
 
 2. the personal location - $BZR_HOME/plugins.
64
 
 
65
 
On a Linux installation, these locations are typically
66
 
``/usr/lib/python2.4/site-packages/bzrlib/plugins/`` and
67
 
``$HOME/.bazaar/plugins/``.
68
 
On a Windows installation, the system location might be
69
 
``C:\\Program Files\\Bazaar\\plugins``
70
 
while the personal location might be
71
 
``C:\Documents and Settings\<username>\Application Data\Bazaar\2.0\plugins``.
72
 
 
73
 
One can additionally override the personal plugins location
74
 
by setting the environment variable ``BZR_PLUGIN_PATH``
75
 
to a directory that contains plugins.
76
 
 
77
 
Listing the installed plugins
78
 
-----------------------------
79
 
 
80
 
To do this, use the plugins command like this::
81
 
 
82
 
    bzr plugins
83
 
 
84
 
The name, location and version of each plugin installed will be displayed.
85
 
 
86
 
New commands added by plugins can be seen by running ``bzr help commands``.
87
 
The commands provided by a plugin are shown followed by the name of the
88
 
plugin in brackets.
89
 
 
90
 
Popular plugins
91
 
---------------
92
 
 
93
 
Here is a sample of some of the more popular plugins.
94
 
 
95
 
  ================ ================= ==================================
96
 
  Category         Name              Description
97
 
  ================ ================= ==================================
98
 
  GUI              QBzr              Qt-based GUI tools
99
 
  GUI              bzr-gtk           GTK-based GUI tools
100
 
  GUI              bzr-eclipse       Eclipse integration
101
 
  General          bzrtools          misc. enhancements including shelf
102
 
  General          difftools         external diff tool helper
103
 
  General          extmerge          external merge tool helper
104
 
  Integration      bzr-svn           use Subversion as a repository
105
 
  Migration        cvsps             migrate CVS patch-sets
106
 
  ================ ================= ==================================
107
 
 
108
 
If you wish to write your own plugins, it is not difficult to do.
109
 
See `Writing a plugin`_ in the appendices to get started.
 
51
than installing ``bzr-gtk`` to ``~/.bazaar/plugins/bzr-gtk``, install it
 
52
to ``~/.bazaar/plugins/gtk``.
 
53
 
 
54
Writing a plugin
 
55
================
 
56
Plugins are very similar to bzr core functionality.  They can import
 
57
anything in bzrlib.  A plugin may simply override standard functionality,
 
58
but most plugins supply new commands.
 
59
 
 
60
To create a command, make a new object that derives from
 
61
``bzrlib.commands.Command``, and name it ``cmd_foo``, where foo is the name of
 
62
your command.  If you create a command whose name contains an underscore,
 
63
it will appear in the UI with the underscore turned into a hyphen.  For
 
64
example, `cmd_baz_import` will appear as `baz-import`.  For examples of how
 
65
to write commands, please see ``builtins.py``.
 
66
 
 
67
Once you've created a command you must register the command with
 
68
``bzrlib.commands.register_command(cmd_foo)``.  You must register the
 
69
command when your file is imported, otherwise bzr will not see it.
 
70
 
 
71
Bzr will scan ``bzrlib/plugins`` and ``~/.bazaar/plugins`` for plugins
 
72
by default.  You can override this with ``BZR_PLUGIN_PATH``.  Plugins
 
73
may be either modules or packages.  If your plugin is a single file,
 
74
you can structure it as a module.  If it has multiple files, or if you
 
75
want to distribute it as a bzr branch, you should structure it as a
 
76
package, i.e. a directory with an ``__init__.py`` file.
 
77
 
 
78
Please feel free to contribute your plugin to BzrTools, if you think it
 
79
would be useful to other people.
 
80