19
19
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
20
20
from bzrlib.branch import Branch
21
from bzrlib.xml5 import serializer_v5
21
from bzrlib.revision import Revision
24
25
class TestBasisInventory(TestCaseWithWorkingTree):
49
50
t._control_files.get_utf8('basis-inventory')
51
52
basis_inv_txt = t.read_basis_inventory()
52
basis_inv = serializer_v5.read_inventory_from_string(basis_inv_txt)
53
basis_inv = bzrlib.xml5.serializer_v5.read_inventory_from_string(basis_inv_txt)
53
54
self.assertEquals('r2', basis_inv.revision_id)
54
55
store_inv = b.repository.get_inventory('r2')
56
57
self.assertEquals(store_inv._byid, basis_inv._byid)
59
def test_basis_inv_gets_revision(self):
60
"""When the inventory of the basis tree has no revision id it gets set.
62
It gets set during set_last_revision.
64
tree = self.make_branch_and_tree('.')
66
tree.branch.repository.control_weaves.get_weave('inventory',
67
tree.branch.repository.get_transaction()
68
).add_lines('r1', [], [
69
'<inventory format="5">\n',
71
rev = Revision(timestamp=0,
73
committer="Foo Bar <foo@example.com>",
78
tree.branch.repository.add_revision('r1', rev)
80
tree.branch.append_revision('r1')
81
tree.set_last_revision('r1')
82
# TODO: we should deserialise the file here, rather than peeking
83
# without parsing, but to do this properly needs a serialiser on the
84
# tree object that abstracts whether it is xml/rio/etc.
85
self.assertContainsRe(
86
tree._control_files.get_utf8('basis-inventory').read(),