Plugin Development Help

Jelmer Vernooij jelmer at samba.org
Tue Jul 24 22:13:35 UTC 2012


Hi Alex,

On Tue, Jul 24, 2012 at 04:52:32PM +0000, Alex Lewis wrote:
>   I hope you don't mind me posting here but if possible I'd like some help with 
> a plugin for Bazaar I'm trying to develop. I'll warn you now this is the first 
> time I've tried python and the first time I've tried to develop a Bazaar plugin 
> so you might need to be a bit gentle :)

>   The plugin I'm trying to develop is one to add the ability to set a "Task-ID" 
> on the revision data. So I'm aiming to add a "--task-id=<value>" option to at 
> least the commit and log commands. So on commit a task-id can be specified to 
> indicate what task the committed changes are for. Log will be extended to log 
> revisions for a given task-id, also applying the other standard logging options 
> if specified. Eventually I guess I'll need to extend merge to ensure the task-id 
> data is brought across and flattened appropriately in the target. Does this all 
> sound reasonable?

>   I've had a play and so far I've been able to add the --task-id option to the 
> commit command in a couple of ways. The two ways I've tried is either to use the 
> extend_command hook or to create a sub-class of cmd_commit in builtins. Is there 
> an official way or best practice for doing this?
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.

>   The theory is to add the task-id data to the revision data on commit. From 
> what I can tell the revprops array on Commit might be a good place to put the 
> data? The problem is I don't seem to be able to get to the revprops array from 
> my plugin code through any hooks and I've tried a number of other ways. Does 
> adding the task-id to the revprops array sound like the right thing to do? If so 
> how do I go about doing this or if not what should I do instead?
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 ?

Cheers,

Jelmer



More information about the bazaar mailing list