Plugin Development Help

Alex Lewis alex.lewis001 at gmail.com
Wed Jul 25 09:31:23 UTC 2012


Thanks Jelmer!

Jelmer Vernooij <jelmer <at> samba.org> writes:
> That's probably the easiest thing to do. You could also just override
> the implementation of the entire commands, as bzr-loom is doing for
> some commands. That works, but may break if other plugins are trying
> to do the same thing.

If possible I think I'd like to avoid having to copy the implementation of 
cmd_commit into my plugin. It just feels a bit brittle when Bazaar is changed, 
incompatibility with other plugins, etc. I'd like to keep my plugin as simple 
and compatible as possible.

> Adding it to Commit.revprops sounds reasonable to me. I'm a bit unsure
> though how you would want to do this exactly. If you're overriding
> cmd_commit anyway to add a new option, wouldn't it make more sense to
> update the revprops dictionary in cmd_commit.run ?

Ok this is probably my lack of python knowledge showing here. I've overridden 
cmd_commit, added my new option to the "takes_options" dictionary, overridden 
"run" which processes **kw to find the value for my new option, then calls 
super(cmd_commit, self).run(*args, **kw) to finish off the command. Obviously at 
this point my task-id value is lost as it isn't passed in any way to the super 
implementation. 

The super implementation of cmd_commit defines the "properties" dictionary 
within the run() function, which it populates with 'bugs' if present and passes 
that into tree.commit(...) as the revprops argument. As "properties" is 
defined/initialised inside cmd_commit.run() I thought I wouldn't be able to add 
my task-id to that dictionary. Is that correct? If I'm wrong how do I add my 
task-id to properties/revprops before it gets sent to tree.commit?

Obviously if I completely override the entire implementation of run I could add 
it but like I say I'd like to avoid having to re-implement run.

Thank you for your help it is greatly appreciated.

Cheers,
Alex




More information about the bazaar mailing list