~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_check.py

  • Committer: Andrew Bennetts
  • Date: 2007-09-28 08:18:16 UTC
  • mto: This revision was merged to the branch mainline in revision 2905.
  • Revision ID: andrew.bennetts@canonical.com-20070928081816-lr6osqf34xiztnff
Use scenario in test_check too, and make check actually report inconsistent parents to the end user.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.repository import _RevisionTextVersionCache
29
29
from bzrlib.tests.repository_implementations import (
30
30
    TestCaseWithInconsistentRepository,
 
31
    TooManyParentsScenario,
31
32
    )
32
33
 
33
34
 
137
138
        result = self.find_bad_ancestors('file2-id', ['rev3'])
138
139
        self.assertEqual({'rev1c': set(['rev3'])}, result)
139
140
 
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'].
145
 
        """
146
 
        inv = self.make_one_file_inventory(
147
 
            repo, 'bad-parent', [], root_revision='bad-parent')
148
 
        self.add_revision(repo, 'bad-parent', inv, [])
149
 
        
150
 
        inv = self.make_one_file_inventory(
151
 
            repo, 'good-parent', ['bad-parent'])
152
 
        self.add_revision(repo, 'good-parent', inv, ['bad-parent'])
153
 
        
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'])
157
 
 
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()
163
 
        self.assertEqual(
164
 
            [('broken-revision', 'a-file-id',
165
 
              ['good-parent', 'bad-parent'], ['good-parent']),
166
 
            ],
167
 
            check_result.inconsistent_parents)
168
 
 
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, [])
172
 
 
173
 
        inv = self.make_one_file_inventory(repo, 'new-revision', ['parent'])
174
 
        self.add_revision(repo, 'new-revision', inv, ['parent'])
175
 
        
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)
183
 
        self.assertEqual(
184
 
            weave.calculate_parents(
185
 
                'new-revision',
186
 
                revision_versions.get_text_version,
187
 
                'a-file-id',
188
 
                revision_parents,
189
 
                repo.get_graph(),
190
 
                repo.get_inventory),
191
 
            ['parent'])
 
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),
 
150
                pattern)
192
151