[PATCH] ROOT gets a file_id
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 17 03:35:30 BST 2005
Michael Ellerman wrote:
>Aside from your use case, which seems reasonable to me, it'd be nice to give
>the root an id so that it's not a special case.
>
>I can't remember which patch it was, but at some point I had to work around
>the fact that the root isn't really there. ie. inventory entries that are
>children of the root don't have a parent_id.
>
>cheers
>
>
>
Well, internal in the bzrlib code right now, if you when you load an
Inventory, you have:
parent_id = elt.get('parent_id')
if parent_id == None:
parent_id = ROOT_ID
Where ROOT_ID = "TREE_ROOT"
So technically they do have a parent_id, it just isn't stored in the XML.
Looking at the code, I see that there is a "RootEntry" object, which is
created using the default ROOT id. I know it makes reference to using a
nested structure, rather than having each entry reference it's parent.
But I still think the tree root shouldn't be special cased, and should
thus have a file_id.
The attached patch seems to at least track the id of a root properly.
It generates a random one when you do branch.init()
It also changes "bzr check --update" so that it will create a unique
tree-root if one is missing, and make sure all of the inventory entries
use it. This does end up changing *all* of the inventory-store entries,
as well as all of the revision-store entries (since they keep track of
the sha1sum of the inventory entries.)
The one problem with this patch, is that trees that are updated, are no
longer compatible with older versions of bzr (because it thinks the
inventory is missing the parent_id for the root-level items).
The easiest thing to do would be to leave the XML as not including a
parent_id, and just having parent_id implicitly be the real root id.
This means that old bzr will create non-standard inventory entries,
however, I'm pretty sure that bzr check --update will update it back to
the correct value (if there is an earlier root id, check --update uses it).
The second patch implements this.
John
=:->
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: root-has-id.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20050616/2971822f/attachment.diff
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hide-parent-for-root-entries.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20050616/2971822f/attachment-0001.diff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050616/2971822f/attachment.pgp
More information about the bazaar
mailing list