137
138
result = self.find_bad_ancestors('file2-id', ['rev3'])
138
139
self.assertEqual({'rev1c': set(['rev3'])}, result)
140
def too_many_parents_factory(self, repo):
141
"""Build a repository where 'broken-revision' of 'a-file' claims to
142
have parents ['good-parent', 'bad-parent']. However 'bad-parent' is in
143
the ancestry of 'good-parent', so the correct parent list for that file
144
version are is just ['good-parent'].
146
inv = self.make_one_file_inventory(
147
repo, 'bad-parent', [], root_revision='bad-parent')
148
self.add_revision(repo, 'bad-parent', inv, [])
150
inv = self.make_one_file_inventory(
151
repo, 'good-parent', ['bad-parent'])
152
self.add_revision(repo, 'good-parent', inv, ['bad-parent'])
154
inv = self.make_one_file_inventory(
155
repo, 'broken-revision', ['good-parent', 'bad-parent'])
156
self.add_revision(repo, 'broken-revision', inv, ['good-parent'])
158
141
def test_too_many_parents(self):
159
repo = self.make_repository_using_factory(
160
self.too_many_parents_factory)
142
scenario = TooManyParentsScenario(self)
143
repo = self.make_repository_using_factory(scenario.populate_repository)
161
144
self.require_text_parent_corruption(repo)
162
145
check_result = repo.check()
164
[('broken-revision', 'a-file-id',
165
['good-parent', 'bad-parent'], ['good-parent']),
167
check_result.inconsistent_parents)
169
def single_parent_changed_in_revision_factory(self, repo):
170
inv = self.make_one_file_inventory(repo, 'parent', [])
171
self.add_revision(repo, 'parent', inv, [])
173
inv = self.make_one_file_inventory(repo, 'new-revision', ['parent'])
174
self.add_revision(repo, 'new-revision', inv, ['parent'])
176
def test_single_parent_changed_in_revision(self):
177
repo = self.make_repository_using_factory(
178
self.single_parent_changed_in_revision_factory)
179
self.require_text_parent_corruption(repo)
180
weave = repo.weave_store.get_weave('a-file-id', repo.get_transaction())
181
revision_parents = repository._RevisionParentsProvider(repo)
182
revision_versions = repository._RevisionTextVersionCache(repo)
184
weave.calculate_parents(
186
revision_versions.get_text_version,
146
check_result.report_results(verbose=True)
147
for pattern in scenario.check_regexes():
148
self.assertContainsRe(
149
self._get_log(keep_log_file=True),