[RFC] Inventory.__delitem__ considered harmful

Robert Collins robertc at robertcollins.net
Thu Sep 7 23:45:59 BST 2006


On Thu, 2006-09-07 at 08:07 -0400, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Robert Collins wrote:
> > Inventory.__delitem__ is rather dangerous at the moment: it breaks the
> > inventory invariant that all the parents of an entry are present in the
> > inventory.
> > 
> > I'd like to just remove it with extreme prejuidice - any objections?
> 
> TreeTransform uses it: see TreeTransform._apply_removals.  Can we just
> fix it so it doesn't violate that invariant?  I can't think of a better
> way to express the functionality TreeTransform needs than del
> inventory[file_id].


I've had a look, and I'm entirely sure I get the code - but if I do,
then limbo_inv is an inventory that is parallel to the working one.

So, it looks to me like because you are going child to parent:
 - you can use remove_recursive_id rather than del.
 - when you move items to limbo, your limbo inventory has its invariants
broken, but the working one is consistent the whole time.

I wonder if giving Inventory the ability to manage limbo for you would
be appropriate? That is, reserve a directory called '.bzr-limbo' with
file-id '.bzr-limbo' in every inventory for the tree-transform code. You
can use this with real trees to store disk resources that are in limbo,
and with inventories to stash inventory entries. We'd update
parent-child pointers etc as they are moved in-and-out of there.

-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: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060908/c941bb61/attachment.pgp 


More information about the bazaar mailing list