~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_pack_repository.py

  • Committer: Robert Collins
  • Date: 2009-08-04 04:36:34 UTC
  • mfrom: (4583 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090804043634-2iu9wpcgs273i97s
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    upgrade,
39
39
    workingtree,
40
40
    )
 
41
from bzrlib.repofmt import (
 
42
    pack_repo,
 
43
    groupcompress_repo,
 
44
    )
41
45
from bzrlib.repofmt.groupcompress_repo import RepositoryFormatCHK1
42
46
from bzrlib.smart import (
43
47
    client,
234
238
        pack_names = [node[1][0] for node in index.iter_all_entries()]
235
239
        self.assertTrue(large_pack_name in pack_names)
236
240
 
 
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
 
246
        repo.lock_write()
 
247
        try:
 
248
            repo.start_write_group()
 
249
            try:
 
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",
 
255
                    revision_id="A")
 
256
                rev.parent_ids = ()
 
257
                repo.add_revision("A", rev, inv=inv)
 
258
            except:
 
259
                repo.abort_write_group()
 
260
                raise
 
261
            else:
 
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)
 
267
        finally:
 
268
            repo.unlock()
 
269
 
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])
489
521
 
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')
557
589
 
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)
562
599
        return repo
563
600
 
564
601
    def test_missing_inventories_compression_parent_prevents_commit(self):
565
602
        repo = self.make_write_ready_repo()
566
603
        key = ('junk',)
567
 
        if not getattr(repo.inventories._index, '_missing_compression_parents',
568
 
            None):
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()
574
 
        repo.unlock()
575
607
 
576
608
    def test_missing_revisions_compression_parent_prevents_commit(self):
577
609
        repo = self.make_write_ready_repo()
578
610
        key = ('junk',)
579
 
        if not getattr(repo.inventories._index, '_missing_compression_parents',
580
 
            None):
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()
586
 
        repo.unlock()
587
614
 
588
615
    def test_missing_signatures_compression_parent_prevents_commit(self):
589
616
        repo = self.make_write_ready_repo()
590
617
        key = ('junk',)
591
 
        if not getattr(repo.inventories._index, '_missing_compression_parents',
592
 
            None):
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()
598
 
        repo.unlock()
599
621
 
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',
604
 
            None):
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()
610
 
        repo.unlock()
611
628
 
612
629
    def test_supports_external_lookups(self):
613
630
        repo = self.make_repository('.', format=self.get_format())