Plugin naming

John Arbash Meinel john at arbash-meinel.com
Sun Jun 29 16:21:06 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Russel Winder wrote:
| The context here is using Bazaar to download branches of plugins to
| ~/.bazaar/plugins on Ubuntu.  The example I am using is bzr-rebase.

The convention for all bzr plugins is to name them "bzr-PLUGIN" where
the final name should be "PLUGIN" on disk. They might also be
"bzr-PLUGIN-NAME" which should be translated to PLUGIN_NAME on disk.

The only plugin I know of offhand that doesn't follow this convention is
"bzrtools" which gets copied as is.

The reasons why-

1) For a while, Launchpad wanted to use names that were easier for
humans to understand. And it *is* easier to communicate "bzr hyphen
rebase" rather than "bzr underscore rebase" to people who aren't
programmers. IIRC, Launchpad recently caved on this, because underscores
exist out there, and too many people are using them.

2) It would be rude to usurp the top-level naming for every plugin we
have. Such as "bzr-stats", "bzr-rebase", "bzr-pqm", "bzr-gtk" etc. It is
just carving out a little namespace (bzr-) that helps for things like
packaging, and listing on a place like Launchpad. (Certainly I think you
could see why we wouldn't want the project to be named "gtk" in Launchpad.)

3) The "bzr-" is redundant when installed into ~/.bazaar/plugins. The
convention *could* be to have all the plugins installed as
"bzrlib.plugins.bzr_rebase.XXX" and bzr_cvsps_import, etc.

4) If you actually read the error, bzr is suggesting the proper name:

|
| If I branch a bzr-rebase branch as bzr-rebase then on next use of
| Bazaar, you get error message:
|
| Unable to load 'bzr-rebase' in '/home/users/russel/.bazaar/plugins' as a
| plugin because the file path isn't a valid module name; try renaming it
| to 'rebase'.

^-- "try renaming it to 'rebase'." We don't suggest "bzr_rebase" and you
are second guessing our recommendation.

When you name it "bzr_rebase" you only have a problem because you have a
site-wide installation of 'rebase' so it ends up finding it twice.
However, other bzr plugins must be installed at their official name
(bzrtools, bzr-gtk, and bzr-svn all will fail if you don't name them
correctly.)

John
=:->


|
| OK, I know the reason, - is not a valid in an identifier in Python.
| This raises the whole question of using - in the name of the plugins.
|
| If I then move the branch directory to bzr_rebase then I get:
|
|  Two plugins defined the same command: 'cmd_replay'
| Not loading the one in <module 'bzrlib.plugins.rebase' from
| '/usr/lib/python2.5/site-packages/bzrlib/plugins/rebase/__init__.pyc'>
| Previously this command was registered from <module
| 'bzrlib.plugins.bzr_rebase' from
| '/home/users/russel/.bazaar/plugins/bzr_rebase/__init__.pyc'>
| Two plugins defined the same command: 'cmd_rebase'
| Not loading the one in <module 'bzrlib.plugins.rebase' from
| '/usr/lib/python2.5/site-packages/bzrlib/plugins/rebase/__init__.pyc'>
| Previously this command was registered from <module
| 'bzrlib.plugins.bzr_rebase' from
| '/home/users/russel/.bazaar/plugins/bzr_rebase/__init__.pyc'>
| Two plugins defined the same command: 'cmd_rebase_abort'
| Not loading the one in <module 'bzrlib.plugins.rebase' from
| '/usr/lib/python2.5/site-packages/bzrlib/plugins/rebase/__init__.pyc'>
| Previously this command was registered from <module
| 'bzrlib.plugins.bzr_rebase' from
| '/home/users/russel/.bazaar/plugins/bzr_rebase/__init__.pyc'>
| Two plugins defined the same command: 'cmd_rebase_continue'
| Not loading the one in <module 'bzrlib.plugins.rebase' from
| '/usr/lib/python2.5/site-packages/bzrlib/plugins/rebase/__init__.pyc'>
| Previously this command was registered from <module
| 'bzrlib.plugins.bzr_rebase' from
| '/home/users/russel/.bazaar/plugins/bzr_rebase/__init__.pyc'>
| Two plugins defined the same command: 'cmd_rebase_todo'
| Not loading the one in <module 'bzrlib.plugins.rebase' from
| '/usr/lib/python2.5/site-packages/bzrlib/plugins/rebase/__init__.pyc'>
| Previously this command was registered from <module
| 'bzrlib.plugins.bzr_rebase' from
| '/home/users/russel/.bazaar/plugins/bzr_rebase/__init__.pyc'>
|
| which is clearly very bad indeed.  It indicates that the name of the
| plugin is really going to have to obey some rules, and yet the name that
| a branch branches to by default is a free variable.  Clearly there are
| constraints on naming, which means that there need to be enforced rules
| as to what names can and cannot be used for plugins.
|
| Moving the directory then to rebase means everything appears to work
| fine.  Well except that the name o fhte plugin and the name of the
| directory in which the plugin resides are not the same which is very
| irritating.
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhnqGEACgkQJdeBCYSNAAOVggCfbBbKu1FgrSlpCWx3m//qom81
b2wAn1lU9Z/VEmTT9mbBZm16W2hMi1/Q
=BjSY
-----END PGP SIGNATURE-----



More information about the bazaar mailing list