234
238
pack_names = [node[1][0] for node in index.iter_all_entries()]
235
239
self.assertTrue(large_pack_name in pack_names)
241
def test_commit_write_group_returns_new_pack_names(self):
242
format = self.get_format()
243
tree = self.make_branch_and_tree('foo', format=format)
244
tree.commit('first post')
245
repo = tree.branch.repository
248
repo.start_write_group()
250
inv = inventory.Inventory(revision_id="A")
251
inv.root.revision = "A"
252
repo.texts.add_lines((inv.root.file_id, "A"), [], [])
253
rev = _mod_revision.Revision(timestamp=0, timezone=None,
254
committer="Foo Bar <foo@example.com>", message="Message",
257
repo.add_revision("A", rev, inv=inv)
259
repo.abort_write_group()
262
old_names = repo._pack_collection._names.keys()
263
result = repo.commit_write_group()
264
cur_names = repo._pack_collection._names.keys()
265
new_names = list(set(cur_names) - set(old_names))
266
self.assertEqual(new_names, result)
237
270
def test_fail_obsolete_deletion(self):
238
271
# failing to delete obsolete packs is not fatal
239
272
format = self.get_format()
484
517
def restoreFactory():
485
518
ui.ui_factory = old_factory
486
519
self.addCleanup(restoreFactory)
487
ui.ui_factory = ui.SilentUIFactory()
488
ui.ui_factory.stdin = StringIO("y\n")
520
ui.ui_factory = ui.CannedInputUIFactory([True])
490
522
def test_break_lock_breaks_physical_lock(self):
491
523
repo = self.make_repository('.', format=self.get_format())
556
588
missing_ghost.get_inventory, 'ghost')
558
590
def make_write_ready_repo(self):
559
repo = self.make_repository('.', format=self.get_format())
591
format = self.get_format()
592
if isinstance(format.repository_format, RepositoryFormatCHK1):
593
raise TestNotApplicable("No missing compression parents")
594
repo = self.make_repository('.', format=format)
560
595
repo.lock_write()
596
self.addCleanup(repo.unlock)
561
597
repo.start_write_group()
598
self.addCleanup(repo.abort_write_group)
564
601
def test_missing_inventories_compression_parent_prevents_commit(self):
565
602
repo = self.make_write_ready_repo()
567
if not getattr(repo.inventories._index, '_missing_compression_parents',
569
raise TestSkipped("No missing compression parents")
570
604
repo.inventories._index._missing_compression_parents.add(key)
571
605
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
572
606
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
573
repo.abort_write_group()
576
608
def test_missing_revisions_compression_parent_prevents_commit(self):
577
609
repo = self.make_write_ready_repo()
579
if not getattr(repo.inventories._index, '_missing_compression_parents',
581
raise TestSkipped("No missing compression parents")
582
611
repo.revisions._index._missing_compression_parents.add(key)
583
612
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
584
613
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
585
repo.abort_write_group()
588
615
def test_missing_signatures_compression_parent_prevents_commit(self):
589
616
repo = self.make_write_ready_repo()
591
if not getattr(repo.inventories._index, '_missing_compression_parents',
593
raise TestSkipped("No missing compression parents")
594
618
repo.signatures._index._missing_compression_parents.add(key)
595
619
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
596
620
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
597
repo.abort_write_group()
600
622
def test_missing_text_compression_parent_prevents_commit(self):
601
623
repo = self.make_write_ready_repo()
602
624
key = ('some', 'junk')
603
if not getattr(repo.inventories._index, '_missing_compression_parents',
605
raise TestSkipped("No missing compression parents")
606
625
repo.texts._index._missing_compression_parents.add(key)
607
626
self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
608
627
e = self.assertRaises(errors.BzrCheckError, repo.commit_write_group)
609
repo.abort_write_group()
612
629
def test_supports_external_lookups(self):
613
630
repo = self.make_repository('.', format=self.get_format())