18
18
"""Test operations that check the repository for corruption"""
22
20
from bzrlib import (
24
21
config as _mod_config,
27
22
revision as _mod_revision,
29
from bzrlib.tests import TestNotApplicable
30
24
from bzrlib.tests.per_repository import TestCaseWithRepository
31
from bzrlib.tests.per_repository.helpers import (
32
TestCaseWithBrokenRevisionIndex,
36
27
class TestNoSpuriousInconsistentAncestors(TestCaseWithRepository):
49
40
self.assertContainsRe(self.get_log(), "0 unreferenced text versions")
52
class TestFindInconsistentRevisionParents(TestCaseWithBrokenRevisionIndex):
54
def test__find_inconsistent_revision_parents(self):
55
"""_find_inconsistent_revision_parents finds revisions with broken
58
repo = self.make_repo_with_extra_ghost_index()
60
[('revision-id', ('incorrect-parent',), ())],
61
list(repo._find_inconsistent_revision_parents()))
63
def test__check_for_inconsistent_revision_parents(self):
64
"""_check_for_inconsistent_revision_parents raises BzrCheckError if
65
there are any revisions with inconsistent parents.
67
repo = self.make_repo_with_extra_ghost_index()
70
repo._check_for_inconsistent_revision_parents)
72
def test__check_for_inconsistent_revision_parents_on_clean_repo(self):
73
"""_check_for_inconsistent_revision_parents does nothing if there are
76
repo = self.make_repository('empty-repo')
77
if not repo.revision_graph_can_have_wrong_parents():
78
raise TestNotApplicable(
79
'%r cannot have corrupt revision index.' % repo)
82
repo._check_for_inconsistent_revision_parents() # nothing happens
86
def test_check_reports_bad_ancestor(self):
87
repo = self.make_repo_with_extra_ghost_index()
88
# XXX: check requires a non-empty revision IDs list, but it ignores the
90
check_object = repo.check(['ignored'])
91
check_object.report_results(verbose=False)
92
self.assertContainsRe(self.get_log(),
93
'1 revisions have incorrect parents in the revision index')
94
check_object.report_results(verbose=True)
95
self.assertContainsRe(
97
"revision-id has wrong parents in index: "
98
r"\('incorrect-parent',\) should be \(\)")
101
43
class TestCallbacks(TestCaseWithRepository):
103
45
def test_callback_tree_and_branch(self):