27
27
class TestBranchBuilder(tests.TestCaseWithMemoryTransport):
29
def assertTreeShape(self, entries, tree):
30
"""Check that the tree shape matches expectations."""
29
32
def test_create(self):
30
33
"""Test the constructor api."""
31
34
builder = BranchBuilder(self.get_transport().clone('foo'))
73
76
branch.repository.get_revision(branch.last_revision()).parent_ids)
78
def test_build_snapshot(self):
79
builder = BranchBuilder(self.get_transport().clone('foo'))
80
rev_id1 = builder.build_snapshot(None, 'A-id',
81
[('add', ('', 'a-root-id', 'directory', None)),
82
('add', ('a', 'a-id', 'file', 'contents'))])
83
self.assertEqual('A-id', rev_id1)
84
branch = builder.get_branch()
85
self.assertEqual((1, rev_id1), branch.last_revision_info())
86
rev_tree = branch.repository.revision_tree(rev_id1)
88
self.addCleanup(rev_tree.unlock)
89
entries = [(path, ie.file_id, ie.kind)
90
for path, ie in rev_tree.iter_entries_by_dir()]
91
self.assertEqual([(u'', 'a-root-id', 'directory'),
92
(u'a', 'a-id', 'file')], entries)
93
self.assertEqual('contents', rev_tree.get_file_text('a-id'))