30
30
TestCaseWithRepository,
31
31
all_repository_vf_format_scenarios,
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
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'))
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'))
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
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'))
293
296
def test_text_from_ghost_revision(self):
294
297
repo = self.make_repository('text-from-ghost')