[MERGE] Enable merging into PreviewTree

Robert Collins robertc at robertcollins.net
Thu Oct 9 06:02:33 BST 2008


On Tue, 2008-09-30 at 15:36 -0500, John Arbash Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> ...
> 
> > usage with other methods, so getting a single entry via
> > iter_entries_by_dir is not uncommon.  That said, I'd be happy to make
> > Tree.get_inventory_entry a Tree method.
> > 
> > Aaron
> 
> I think it would be great to have something like this. There are a few
> cases where we just want a simple member of an inventory entry, like
> "IE.revision()" and we end up having to go through
> "tree.inventory[file_id].revision".
> 
> Certainly WT4 and DirStateRevisionTree can implement it without having
> to build the whole Inventory which is very nice for simple probes. I
> don't remember exactly when I was running into this in the past, but it
> is certainly something that I remember wanting.

It feels strange to me to have a method on Tree to get an
InventoryEntry.

Tree's are different to Inventories in that:
  A tree can have missing and extra paths
  A tree can be out of sync with its inventory in other ways - kind,
    file_size, etc.

In my opinion the goal for reducing the usage of inventory is to move
code that is unaware of these difference because its on inventory, to
the apis on tree that reflect these difference, rather than simply
getting rid of the .inventory attribute.

I'd rather it was clear in our code about where we are using inventories
and inventory entries :- in this particular case it should be straight
forward to subclass Inventory with a dynamic __getitem__ and __iter__
method. I did this in my split inventory work (along with a couple of
minor tweaks to not using _byid in methods on Inventory) to implement
demand-loading of inventory data from individual fragments.

-Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20081009/be15bb2c/attachment.pgp 


More information about the bazaar mailing list