Ejemplo n.º 1
0
 def test_shared_repos(self):
     self.make_repository('a', shared=True)
     BzrDir.create_branch_convenience('a/branch1')
     b = BzrDir.create_branch_convenience('a/branch2')
     b.create_checkout(lightweight=True, to_location='b')
     out, err = self.run_bzr('branches b')
     self.assertEqual(out, "  branch1\n"
                           "* branch2\n")
Ejemplo n.º 2
0
    def setUp(self):
        super(TestsNeedingReweave, self).setUp()

        t = self.get_transport()
        # an empty inventory with no revision for testing with.
        repo = self.make_repository('inventory_without_revision')
        repo.lock_write()
        repo.start_write_group()
        inv = Inventory(revision_id=b'missing')
        inv.root.revision = b'missing'
        repo.add_inventory(b'missing', inv, [])
        repo.commit_write_group()
        repo.unlock()

        def add_commit(repo, revision_id, parent_ids):
            repo.lock_write()
            repo.start_write_group()
            inv = Inventory(revision_id=revision_id)
            inv.root.revision = revision_id
            root_id = inv.root.file_id
            sha1 = repo.add_inventory(revision_id, inv, parent_ids)
            repo.texts.add_lines((root_id, revision_id), [], [])
            rev = breezy.revision.Revision(
                timestamp=0,
                timezone=None,
                committer="Foo Bar <*****@*****.**>",
                message="Message",
                inventory_sha1=sha1,
                revision_id=revision_id)
            rev.parent_ids = parent_ids
            repo.add_revision(revision_id, rev)
            repo.commit_write_group()
            repo.unlock()

        # an empty inventory with no revision for testing with.
        # this is referenced by 'references_missing' to let us test
        # that all the cached data is correctly converted into ghost links
        # and the referenced inventory still cleaned.
        repo = self.make_repository('inventory_without_revision_and_ghost')
        repo.lock_write()
        repo.start_write_group()
        repo.add_inventory(b'missing', inv, [])
        repo.commit_write_group()
        repo.unlock()
        add_commit(repo, b'references_missing', [b'missing'])

        # a inventory with no parents and the revision has parents..
        # i.e. a ghost.
        repo = self.make_repository('inventory_one_ghost')
        add_commit(repo, b'ghost', [b'the_ghost'])

        # a inventory with a ghost that can be corrected now.
        t.copy_tree('inventory_one_ghost', 'inventory_ghost_present')
        bzrdir_url = self.get_url('inventory_ghost_present')
        bzrdir = BzrDir.open(bzrdir_url)
        repo = bzrdir.open_repository()
        add_commit(repo, b'the_ghost', [])
Ejemplo n.º 3
0
 def test_reweave_inventory_without_revision_and_ghost(self):
     # actual low level test.
     d_url = self.get_url('inventory_without_revision_and_ghost')
     d = BzrDir.open(d_url)
     repo = d.open_repository()
     if not repo._reconcile_does_inventory_gc:
         raise TestSkipped('Irrelevant test')
     # nothing should have been altered yet : inventories without
     # revisions are not data loss incurring for current format
     self.check_thorough_reweave_missing_revision(d, repo.reconcile,
                                                  thorough=True)
Ejemplo n.º 4
0
 def test_convenience_reconcile_inventory_without_revision_reconcile(self):
     # smoke test for the all in one ui tool
     bzrdir_url = self.get_url('inventory_without_revision')
     bzrdir = BzrDir.open(bzrdir_url)
     repo = bzrdir.open_repository()
     if not repo._reconcile_does_inventory_gc:
         raise TestSkipped('Irrelevant test')
     reconcile(bzrdir)
     # now the backup should have it but not the current inventory
     repo = bzrdir.open_repository()
     self.check_missing_was_removed(repo)
Ejemplo n.º 5
0
    def test_reweave_inventory_without_revision_reconciler(self):
        # smoke test for the all in one Reconciler class,
        # other tests use the lower level repo.reconcile()
        d_url = self.get_url('inventory_without_revision_and_ghost')
        d = BzrDir.open(d_url)
        if not d.open_repository()._reconcile_does_inventory_gc:
            raise TestSkipped('Irrelevant test')

        def reconcile():
            reconciler = Reconciler(d)
            return reconciler.reconcile()
        self.check_thorough_reweave_missing_revision(d, reconcile)
Ejemplo n.º 6
0
 def checkEmptyReconcile(self, **kwargs):
     """Check a reconcile on an empty repository."""
     self.make_repository('empty')
     d = BzrDir.open(self.get_url('empty'))
     # calling on a empty repository should do nothing
     result = d.find_repository().reconcile(**kwargs)
     # no inconsistent parents should have been found
     self.assertEqual(0, result.inconsistent_parents)
     # and no garbage inventories
     self.assertEqual(0, result.garbage_inventories)
     # and no backup weave should have been needed/made.
     self.checkNoBackupInventory(d)
Ejemplo n.º 7
0
 def test_reweave_inventory_preserves_a_revision_with_ghosts(self):
     d = BzrDir.open(self.get_url('inventory_one_ghost'))
     reconciler = d.open_repository().reconcile(thorough=True)
     # no inconsistent parents should have been found:
     # the lack of a parent for ghost is normal
     self.assertEqual(0, reconciler.inconsistent_parents)
     # and one garbage inventories
     self.assertEqual(0, reconciler.garbage_inventories)
     # now the current inventory should still have 'ghost'
     repo = d.open_repository()
     repo.get_inventory(b'ghost')
     self.assertThat([b'ghost', b'the_ghost'],
                     MatchesAncestry(repo, b'ghost'))
Ejemplo n.º 8
0
 def test_reweave_inventory_without_revision(self):
     # an excess inventory on its own is only reconciled by using thorough
     d_url = self.get_url('inventory_without_revision')
     d = BzrDir.open(d_url)
     repo = d.open_repository()
     if not repo._reconcile_does_inventory_gc:
         raise TestSkipped('Irrelevant test')
     self.checkUnreconciled(d, repo.reconcile())
     result = repo.reconcile(thorough=True)
     # no bad parents
     self.assertEqual(0, result.inconsistent_parents)
     # and one garbage inventory
     self.assertEqual(1, result.garbage_inventories)
     self.check_missing_was_removed(repo)
Ejemplo n.º 9
0
 def test_reweave_inventory_fixes_ancestryfor_a_present_ghost(self):
     d = BzrDir.open(self.get_url('inventory_ghost_present'))
     repo = d.open_repository()
     m = MatchesAncestry(repo, b'ghost')
     if m.match([b'the_ghost', b'ghost']) is None:
         # the repo handles ghosts without corruption, so reconcile has
         # nothing to do
         return
     self.assertThat([b'ghost'], m)
     reconciler = repo.reconcile()
     # this is a data corrupting error, so a normal reconcile should fix it.
     # one inconsistent parents should have been found : the
     # available but not reference parent for ghost.
     self.assertEqual(1, reconciler.inconsistent_parents)
     # and no garbage inventories
     self.assertEqual(0, reconciler.garbage_inventories)
     # now the current inventory should still have 'ghost'
     repo = d.open_repository()
     repo.get_inventory(b'ghost')
     repo.get_inventory(b'the_ghost')
     self.assertThat([b'the_ghost', b'ghost'],
                     MatchesAncestry(repo, b'ghost'))
     self.assertThat([b'the_ghost'], MatchesAncestry(repo, b'the_ghost'))
Ejemplo n.º 10
0
 def t():
     BzrDir.open_from_transport(transport)
     thread_result.append('ok')