detecting version match/mismatch between core/plugins

John Arbash Meinel john at
Tue Aug 15 14:17:06 BST 2006

Wichmann, Mats D wrote:
>>> It would be easy enough to have a version number in the plugin and
>>> fail to load it if it's too low or high, it would just 
>>> require someone to write the code :) 
>> I think its up to the plugin to do that... keeps them more like regular
>> python files.
> Haven't followed up to last few comments, but I
> think I agree that it's the plugin that needs to
> have most of the "smarts".  Somewhere else it was
> suggested to have some plugins release with versions
> that were in lockstep with the core, but that only
> works for stable maintream stuff; doesn't seem
> intuitive that if I'm coding a new plugin I'd have
> to call it 1.2 (even though I want it at 0.1)
> so bzr 1.2 will load it...

There are a lot of possible naming conventions. For example you could
name it 0.1-1.2 if you wanted.

Python is flexible and introspective enough, that you can usually write
compatibility layers without much difficulty. For example:

changes_from = getattr(tree, 'changes_from', None)
if changes_from is None:
  from import compare_trees
  delta = compare_trees(old_tree, tree, ...)
  delta = tree.changes_from(old_tree, ...)

It depends how much it is *worth* maintaining compatibility. I've
written plugins that are compatible across a wide range of versions of
bzr. (Back when we split Branch into Branch and Repository I used stuff
like: repo = getattr(branch, 'repository', branch), since Repository
just inherited the branch functionality. That is until they diverged ...)

If we really want to make it simpler, I suppose we could add a
~/.bazaar/bazaar.conf entry to make it easier to silence the deprecation
warnings. (Or we could just have another plugin do that :)

Anyway, there is always introspection, and you can also use
'bzrlib.version_info' if you want something more course grained.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : 

More information about the bazaar mailing list