bzrlib API question

John A Meinel john at arbash-meinel.com
Tue Feb 21 19:24:00 GMT 2006


Robey Pointer wrote:
> Now that the repository branch has landed, I had to fix a few places
> where I was using bzrlib in one of my projects -- which is okay, I knew
> what I was getting into. :)  But I want to make sure that what I'm doing
> is the "right" way.
> 
> I had lines like:
> 
>     [...] bzrlib.log.find_touching_revisions(b, file_id)
>     rev = b.get_revision(revid)
> 
> and:
> 
>     tree = b.revision_tree(b.get_rev_id(revno))
> 
> which I changed to:
> 
>     [...] bzrlib.log.find_touching_revisions(b, file_id)
>     rev = b.repository.get_revision(revid)
> 
> and:
> 
>     tree = b.repository.revision_tree(b.get_rev_id(revno))
> 
> (In other words, I kept everything the same, but used 'b.respository'
> instead of 'b'.)
> 
> Am I doing the right thing, or is there a better way to do this?
> 
> robey

Well, I tend to make things backwards compatible as much as possible, so
my plugins do:

repo = getattr(branch, 'repository', branch)
rev = repo.get_revision(revid)

But that is a compatibility hack. Use it at your own discretion. (There
are some function names which were changed, but only a few, and they
were private anyway. But for invasive plugins, thats the life we lead).


For the future, I think we have settled that:

 WorkingTrees have a .branch
 Branches have a .repository
 Repositories have nothing :)

Anyway, these are publicly accessible members (they don't start with
'_'), so it is officially correct to access them from outside code. And
we promise to maintain compatibility for at least 6 months, blah blah blah.

Part of why we are trying to break as much stuff as we can right now, is
because when we are done, we want to keep source-level compatibility for
some arbitrary length of time.

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060221/0b868675/attachment.pgp 


More information about the bazaar mailing list