20
20
from bzrlib import (
21
21
config as _mod_config,
23
22
revision as _mod_revision,
25
from bzrlib.tests import TestNotApplicable
26
24
from bzrlib.tests.per_repository import TestCaseWithRepository
27
from bzrlib.tests.per_repository.helpers import (
28
TestCaseWithBrokenRevisionIndex,
32
27
class TestNoSpuriousInconsistentAncestors(TestCaseWithRepository):
45
40
self.assertContainsRe(self.get_log(), "0 unreferenced text versions")
48
class TestFindInconsistentRevisionParents(TestCaseWithBrokenRevisionIndex):
50
def test__find_inconsistent_revision_parents(self):
51
"""_find_inconsistent_revision_parents finds revisions with broken
54
repo = self.make_repo_with_extra_ghost_index()
56
[('revision-id', ('incorrect-parent',), ())],
57
list(repo._find_inconsistent_revision_parents()))
59
def test__check_for_inconsistent_revision_parents(self):
60
"""_check_for_inconsistent_revision_parents raises BzrCheckError if
61
there are any revisions with inconsistent parents.
63
repo = self.make_repo_with_extra_ghost_index()
66
repo._check_for_inconsistent_revision_parents)
68
def test__check_for_inconsistent_revision_parents_on_clean_repo(self):
69
"""_check_for_inconsistent_revision_parents does nothing if there are
72
repo = self.make_repository('empty-repo')
73
if not repo._format.revision_graph_can_have_wrong_parents:
74
raise TestNotApplicable(
75
'%r cannot have corrupt revision index.' % repo)
78
repo._check_for_inconsistent_revision_parents() # nothing happens
82
def test_check_reports_bad_ancestor(self):
83
repo = self.make_repo_with_extra_ghost_index()
84
# XXX: check requires a non-empty revision IDs list, but it ignores the
86
check_object = repo.check(['ignored'])
87
check_object.report_results(verbose=False)
88
self.assertContainsRe(self.get_log(),
89
'1 revisions have incorrect parents in the revision index')
90
check_object.report_results(verbose=True)
91
self.assertContainsRe(
93
"revision-id has wrong parents in index: "
94
r"\('incorrect-parent',\) should be \(\)")
97
43
class TestCallbacks(TestCaseWithRepository):
99
45
def test_callback_tree_and_branch(self):