iterating over revisions in a branch

Jelmer Vernooij jelmer at samba.org
Wed Jan 4 13:05:48 GMT 2006


On Wed, Jan 04, 2006 at 11:56:24PM +1100, Jamie Wilkinson wrote about 'iterating over revisions in a branch':
> Rob gave me a hint on how to iterate over revisoins in a branch:

>   for revision_id in branch.revision_history():
>     revision = branch.get_revision(revision_id)

> It occurred to me just now that it doesn't feel right.  If I'm iterating
> over revisions, I shouldn't have to extract the revision during the body of
> the iterator loop, surely instead of the revision id I should get back the
> whole revision?

Efficiency. The list of revision ids can be read directly from the
.bzr/revision-history file. Reading the revision itself requires reading 
the appropriate file in .bzr/revisions/ (amongst other files). 

If, for example, you would only want to do something with the last two 
revisions, that would not require reading all revisions that exist in
the revision history. Also, for things like 'revno' (which is
basically length(branch.revision_history()) the revision contents don't
matter.

Cheers,

Jelmer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060104/0eef2c25/attachment.pgp 


More information about the bazaar mailing list