getting the inventory of a revision, or, Why doesn't the API look like I think it should?

Aaron Bentley aaron.bentley at utoronto.ca
Wed Jan 4 17:31:10 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jamie Wilkinson wrote:

>  * You get the tree from the branch!  Oh, don't need to get the revision
>    now.
>
>  * Examine the inventory from the tree given.

Actually, you can get the inventory directly from the branch, too.

In terms of the logical construction, you do have the containment right.
That is, a branch refers to a series of revisions, revisions consist of
metadata and a tree, a tree consists of an inventory and file contents

I should note that we're in the middle of splitting Repository out of
Branch.  Branch's main responsibility then becomes the history list.

Repository is in responsible for all revision data: revisions,
signatures, inventories, and file contents.

On one hand,

for (branch.get_inventory(r) for r in branch.revision_history())

doesn't seem all that bad to me.

But my gut instinct is that you're wanting a layer that doesn't exist
yet-- a fascade meant to simplify life for external library users.

So
class SmartBranch(object):
    def __init__(self, path):
        object.__init__(self)
        self._branch = Branch.open(path)

    def revision_history(self):
        for revision in self._branch.revision_history():
            yield self.get_revision(revision)

    def get_revision(self, revision):
	return LazyRevision(revision, self._branch)
    ...

class LazyRevision(object):
    def __init__(revision_id, revision_source):
        object.__init__(self)
        self.revision_id = revision_id
        self._revision_source = revision_source
        self._tree = None
        ....

    def _get_tree(self):
        if self._tree is None:
            self._tree = self._revision_source.revision_tree(\
                self.revision_id)
        return self._tree
    tree = property(_get_tree)
    ...


Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDvAZe0F+nu1YWqI0RApzPAJ4p/7SrRiY97SAotD+XS1kNbnwhHgCghUPL
+YSrBNbVHOcu1iW+W+i0HU4=
=YMJa
-----END PGP SIGNATURE-----




More information about the bazaar mailing list