Generate a Diff from a plugin

Patrick Dobbs patrick.dobbs at
Thu Jun 18 16:21:43 BST 2009


We're using BZR with the "Decentralized with shared mainline" workflow. 
We want to integrate with our bug tracker (, but we 
need to be able to work offline. So we've created a Push plugin that 
loops through revisions in the current push, checks each revision for a 
bug id, and then posts this bug through a soap call:

def post_push_hook(push_result):
    current_rev_no = push_result.old_revno
    source = push_result.source_branch
    while current_rev_no <= push_result.new_revno:
        current_rev_id = source.get_rev_id(current_rev_no)
        message = source.repository.get_revision(current_rev_id).message
        bug_message ="[\s|^](\#)(\d+)",message)
        if bug_message:
            bug_id =

However, we'd like to be able to get a diff for each revision at the 
same time (the DIFF will be added to the bug tracker comment). I've dug 
a bit into bzrlib but have got confused with 
branches/trees/repositories/deltas and was hoping that someone more au 
fait with the api could advise me.

So, in summary, can anyone on this list advise me how, given a Branch 
object and two revision numbers, it is best to generate a diff (as a 

Thanks for any suggestions.


More information about the bazaar mailing list