예제 #1
0
 def test_corrupt_revision_access_asserts_if_reported_wrong(self):
     repo_url = self.get_url('inventory_with_unnecessary_ghost')
     repo = _mod_repository.Repository.open(repo_url)
     m = MatchesAncestry(repo, 'ghost')
     reported_wrong = False
     try:
         if m.match(['the_ghost', 'ghost']) is not None:
             reported_wrong = True
     except errors.CorruptRepository:
         # caught the bad data:
         return
     if not reported_wrong:
         return
     self.assertRaises(errors.CorruptRepository, repo.get_revision, 'ghost')
예제 #2
0
 def test_corrupt_revision_access_asserts_if_reported_wrong(self):
     repo_url = self.get_url('inventory_with_unnecessary_ghost')
     repo = _mod_repository.Repository.open(repo_url)
     m = MatchesAncestry(repo, 'ghost')
     reported_wrong = False
     try:
         if m.match(['the_ghost', 'ghost']) is not None:
             reported_wrong = True
     except errors.CorruptRepository:
         # caught the bad data:
         return
     if not reported_wrong:
         return
     self.assertRaises(errors.CorruptRepository, repo.get_revision, 'ghost')
예제 #3
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, 'ghost')
     if m.match(['the_ghost', 'ghost']) is None:
         # the repo handles ghosts without corruption, so reconcile has
         # nothing to do
         return
     self.assertThat(['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('ghost')
     repo.get_inventory('the_ghost')
     self.assertThat(['the_ghost', 'ghost'], MatchesAncestry(repo, 'ghost'))
     self.assertThat(['the_ghost'], MatchesAncestry(repo, 'the_ghost'))
예제 #4
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, 'ghost')
     if m.match(['the_ghost', 'ghost']) is None:
         # the repo handles ghosts without corruption, so reconcile has
         # nothing to do
         return
     self.assertThat(['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('ghost')
     repo.get_inventory('the_ghost')
     self.assertThat(['the_ghost', 'ghost'],
         MatchesAncestry(repo, 'ghost'))
     self.assertThat(['the_ghost'],
         MatchesAncestry(repo, 'the_ghost'))