[PATCH] better python plugins (well, better IMHO)

Lalo Martins lalo at laranja.org
Sun Jun 12 11:30:35 BST 2005

This patch does plug-ins in a different way.

I think it's a mistake to assume plug-ins are going to be used
exclusively for adding commands.  We're doing things quite modularly, so
I think it's reasonable to trust on plugins to implement branch storages
(when/if we have them) and exporters (as per my previous patch), and
other things in the future.  Otherwise we'll end up with a half dozen
"BZR*PATH" variables and a lot of lookups; the added complexity is not
really welcome.  One plugin system to rule them all and in the namespace
bind them.

So I decoupled plugins from commands.  Plugins are now loaded on bzrlib
initialization, and they're free to register whatever components they
like.  On the other hand they have to do so manually.  (Explicit is
better than implicit).  John's code to register a command from a plugin
was moved to an utility function.

A few issues:

- John's code has a comment stating subdirectories from the plugin path
will be searched one level down; but there was nothing on his code that
implemented this.  I didn't add the feature; personally I think it's
silly and will slow down startup.  If you want your plugins in revision
control, either symlink them into somewhere in the plugin path, or put
the source tree in the path - it's a path after all, not a single dir.

- I renamed the environment variable from BZRPLUGINPATH to
BZR_PLUGIN_PATH which seems to be more like the unix standards.  The
(seemingly completely gratuitous) incompatibility is due to the fact
that any plug-ins written for John's code won't work with this version -
they will be loaded, but not register anything.  So I think it's worth
breaking them, so that you have to move them manually and then fix them.
   Feel free to undo this part :-) it's a single-line change.

                                                 Lalo Martins
    It doesn't bother me that people say things like
     "you'll never get anywhere with this attitude".
     In a few decades, it will make a good paragraph
        in my biography. You know, for a laugh.
http://www.laranja.org/                mailto:lalo at laranja.org
           pgp key: http://www.laranja.org/pessoal/pgp

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bzr-plugins.diff
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20050612/bd526dae/attachment.diff 

More information about the bazaar mailing list