[MERGE] filtered-deltas - basis for log DIR
John Arbash Meinel
john at arbash-meinel.com
Fri Mar 20 14:18:55 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
>>> It seems strange for an optimization to be doing a copy.
>> Non-chk inventories are mutable so I'm doing the copying to
>> be safe.
>
> You mean, because someone might mutate the inventory of the returned
> RevisionTree? That's definitely not acceptable behaviour for using a
> RevisionTree.
>
> Or do you mean someone using filter? That could be addressed by
> rejigging filter so it used the current Inventory instead of returning a
> new one.
>
We have some code paths that do something like:
tree = repo.revision_tree()
inv = tree.inventory
...
ie = inv[file_id]
ie.foo = bar
save_new_inventory(inv)
The one I know the most about is the base
Repository.add_inventory_by_delta():
basis_tree = self.revision_tree(basis_revision_id)
basis_tree.lock_read()
try:
# Note that this mutates the inventory of basis_tree, which not all
# inventory implementations may support: A better idiom would be to
# return a new inventory, but as there is no revision tree cache in
# repository this is safe for now - RBC 20081013
basis_inv = basis_tree.inventory
basis_inv.apply_delta(delta)
basis_inv.revision_id = new_revision_id
return (self.add_inventory(new_revision_id, basis_inv, parents),
basis_inv)
finally:
basis_tree.unlock()
At least it has a nice big warning about it. We also have some similar
code in the test suite. Which is why returning exact inventory entries
from _unpack_entry() is currently disabled, even though it save ~25% of
the time for converting from an XML repo into a CHK one. (Note that I
enable it when converting, because I know that code path is safe...)
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknDpc8ACgkQJdeBCYSNAAMHGgCgyTzFg7LSDjyy6L71BipsgvxA
LscAn29vpHoBOqm+eZbEFTXgvG4I14hD
=+NoF
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list