31
31
from bzrlib.delta import TreeDelta
32
from bzrlib.inventory import Inventory, InventoryDirectory
32
from bzrlib.inventory import CommonInventory, Inventory, InventoryDirectory
33
33
from bzrlib.repofmt.weaverepo import (
242
242
invs = tree.branch.repository.iter_inventories(revs)
243
243
for rev_id, inv in zip(revs, invs):
244
244
self.assertEqual(rev_id, inv.revision_id)
245
self.assertIsInstance(inv, Inventory)
245
self.assertIsInstance(inv, CommonInventory)
247
247
def test_supports_rich_root(self):
248
248
tree = self.make_branch_and_tree('a')
250
250
second_revision = tree.commit('')
251
inv = tree.branch.repository.revision_tree(second_revision).inventory
251
rev_tree = tree.branch.repository.revision_tree(second_revision)
253
self.addCleanup(rev_tree.unlock)
254
inv = rev_tree.inventory
252
255
rich_root = (inv.root.revision != second_revision)
253
256
self.assertEqual(rich_root,
254
257
tree.branch.repository.supports_rich_root())
330
333
wt.set_root_id('fixed-root')
331
334
wt.commit('lala!', rev_id='revision-1', allow_pointless=True)
332
335
tree = wt.branch.repository.revision_tree('revision-1')
333
self.assertEqual('revision-1', tree.inventory.root.revision)
334
expected = InventoryDirectory('fixed-root', '', None)
335
expected.revision = 'revision-1'
336
self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)],
337
list(tree.list_files(include_root=True)))
338
self.assertEqual('revision-1', tree.inventory.root.revision)
339
expected = InventoryDirectory('fixed-root', '', None)
340
expected.revision = 'revision-1'
341
self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)],
342
list(tree.list_files(include_root=True)))
338
345
tree = self.callDeprecated(['NULL_REVISION should be used for the null'
339
346
' revision instead of None, as of bzr 0.91.'],
340
347
wt.branch.repository.revision_tree, None)
341
self.assertEqual([], list(tree.list_files(include_root=True)))
350
self.assertEqual([], list(tree.list_files(include_root=True)))
342
353
tree = wt.branch.repository.revision_tree(NULL_REVISION)
343
self.assertEqual([], list(tree.list_files(include_root=True)))
356
self.assertEqual([], list(tree.list_files(include_root=True)))
345
360
def test_get_revision_delta(self):
346
361
tree_a = self.make_branch_and_tree('a')
487
502
tree = self.make_branch_and_tree('.')
488
503
tree.commit('message', rev_id='rev_id')
489
504
rev_tree = tree.branch.repository.revision_tree(tree.last_revision())
506
self.addCleanup(rev_tree.unlock)
490
507
self.assertEqual('rev_id', rev_tree.inventory.root.revision)
492
509
def test_upgrade_from_format4(self):
655
672
repo.get_signature_text('A'))
657
674
def test_add_revision_inventory_sha1(self):
658
repo = self.make_repository('repo')
659
675
inv = Inventory(revision_id='A')
660
676
inv.root.revision = 'A'
661
677
inv.root.file_id = 'fixed-root'
678
# Insert the inventory on its own to an identical repository, to get
680
reference_repo = self.make_repository('reference_repo')
681
reference_repo.lock_write()
682
reference_repo.start_write_group()
683
inv_sha1 = reference_repo.add_inventory('A', inv, [])
684
reference_repo.abort_write_group()
685
reference_repo.unlock()
686
# Now insert a revision with this inventory, and it should get the same
688
repo = self.make_repository('repo')
662
689
repo.lock_write()
663
690
repo.start_write_group()
664
691
repo.add_revision('A', Revision('A', committer='B', timestamp=0,
666
693
repo.commit_write_group()
669
self.assertEquals(osutils.sha_string(
670
repo._serializer.write_inventory_to_string(inv)),
671
repo.get_revision('A').inventory_sha1)
696
self.assertEquals(inv_sha1, repo.get_revision('A').inventory_sha1)
674
699
def test_install_revisions(self):