~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_vf/test_reconcile.py

  • Committer: Jelmer Vernooij
  • Date: 2011-06-16 15:29:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5987.
  • Revision ID: jelmer@samba.org-20110616152910-g33fj0rbpngw9r7j
Use matchers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    TestCaseWithRepository,
31
31
    all_repository_vf_format_scenarios,
32
32
    )
 
33
from bzrlib.tests.matchers import MatchesAncestry
33
34
from bzrlib.tests.scenarios import load_tests_apply_scenarios
34
35
from bzrlib.uncommit import uncommit
35
36
 
194
195
            **kwargs):
195
196
        # actual low level test.
196
197
        repo = aBzrDir.open_repository()
197
 
        if ([None, 'missing', 'references_missing']
198
 
            != repo.get_ancestry('references_missing')):
 
198
        m = MatchesAncestry(repo,'references_missing')
 
199
        if m.matches(['missing', 'references_missing']) is not None:
199
200
            # the repo handles ghosts without corruption, so reconcile has
200
201
            # nothing to do here. Specifically, this test has the inventory
201
202
            # 'missing' present and the revision 'missing' missing, so clearly
215
216
        self.check_missing_was_removed(repo)
216
217
        # and the parent list for 'references_missing' should have that
217
218
        # revision a ghost now.
218
 
        self.assertEqual([None, 'references_missing'],
219
 
                         repo.get_ancestry('references_missing'))
 
219
        self.assertThat(['references_missing'],
 
220
            MatchesAncestry(repo, 'references_missing'))
220
221
 
221
222
    def check_missing_was_removed(self, repo):
222
223
        if repo._reconcile_backsup_inventory:
265
266
        # now the current inventory should still have 'ghost'
266
267
        repo = d.open_repository()
267
268
        repo.get_inventory('ghost')
268
 
        self.assertEqual([None, 'ghost'], repo.get_ancestry('ghost'))
 
269
        self.assertThat(['ghost'], MatchesAncestry(repo, 'ghost'))
269
270
 
270
271
    def test_reweave_inventory_fixes_ancestryfor_a_present_ghost(self):
271
272
        d = bzrlib.bzrdir.BzrDir.open(self.get_url('inventory_ghost_present'))
272
273
        repo = d.open_repository()
273
 
        ghost_ancestry = repo.get_ancestry('ghost')
274
 
        if ghost_ancestry == [None, 'the_ghost', 'ghost']:
 
274
        m = MatchesAncestry(repo, 'ghost')
 
275
        if m.matches(['the_ghost', 'ghost']) is None:
275
276
            # the repo handles ghosts without corruption, so reconcile has
276
277
            # nothing to do
277
278
            return
278
 
        self.assertEqual([None, 'ghost'], ghost_ancestry)
 
279
        self.assertThat(['ghost'], m)
279
280
        reconciler = repo.reconcile()
280
281
        # this is a data corrupting error, so a normal reconcile should fix it.
281
282
        # one inconsistent parents should have been found : the
287
288
        repo = d.open_repository()
288
289
        repo.get_inventory('ghost')
289
290
        repo.get_inventory('the_ghost')
290
 
        self.assertEqual([None, 'the_ghost', 'ghost'], repo.get_ancestry('ghost'))
291
 
        self.assertEqual([None, 'the_ghost'], repo.get_ancestry('the_ghost'))
 
291
        self.assertThat(['the_ghost', 'ghost'],
 
292
            MatchesAncestry(repo, 'ghost'))
 
293
        self.assertThat(['the_ghost'],
 
294
            MatchesAncestry(repo, 'the_ghost'))
292
295
 
293
296
    def test_text_from_ghost_revision(self):
294
297
        repo = self.make_repository('text-from-ghost')