[RFC] deprecate mutable inventories

Robert Collins robertc at robertcollins.net
Tue Sep 12 03:22:28 BST 2006

I know this has been sort-of-mentioned, but I've only just now really
got a clear handle on the issues that have been making me feel that
Inventory is more of a burden than a benefit.

Dirstate wants to hold an optimised structure in memory: possibly a
vector of (path, type, id, stat, ....) details, but even if its a
dictionary its not your typical inventory - because its holding parent
details too.

Why does it want this in memory? because its what it gets directly out
of the disk format, and *its still* fast in memory for doing a large
range of queries. (such as walkdirs and subpath selection).

Inventory objects make this harder for the Dirstate based tree because
theres no aliasing: someone can change an inventory entry and dirstate
will no notice.(Yes, I can write Inventory entries that back into the
dirstate, as an alternate implementation. I think I'll have to for
compatability). (file_id -> path indexing is part of offering an
Inventory interface, we'll need that regardless for efficiency).

What would be ideal IMO is that we remove the _inventory attribute of
all trees, and make the Tree interface satisfy our needs efficiently.

Then mutation operations on Tree take the place of the current
poke-at-inventory logic.

TreeTransform will need some assistance here - the current unversion()
call is part of that, but AIUI the next step is allowing the
transformations that violate posix to have a limbo working area.

As a for instance on why this is important, consider the trivial case of
unversion. unversion of in dirstate *does not remove the row*. Say we
are unversioning 'foo' with id 'foo-id', which is in the basis tree.
We go from:
'foo', 'foo', 'f', statdata, 'foo-id', 'f', 'rev1', 'f', '', 'foo',
'123', 'n', 'abcdef012345678123791231231231234123'

'', '', '', statdata, 'foo-id', '', 'rev1', '', 'foo', '123', 'n',

The fields that change are the relpath (it is not versioned anymore, no
path), name(ditto), file type (ditto).

Typical Inventory unversion is to delete the object, but thats not
appropriate here.

(See my other email for a variation on this, where we have two stages of
cleanup - but still, until the file-id has no references in the set of
all inventories for the tree - the parents and the current one - it will
have a row in the tree).

consider a subdir in dirstate: there are no parent pointers - each row
is key data followed by the parent data for this path:
 relpath, name, kind, stat, file_id, versionedkind, [[revision, kind,
dirname, basename, size, executable, sha1] ...]

So an operation like 'rename the base directory' for dirstate does
actually need to do deeper updates than inventory can represent


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/20060912/a89a315f/attachment.pgp 

More information about the bazaar mailing list