/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        make sure we safely detect this problem.
74
74
        """
75
75
        repo = self.make_repo_with_extra_ghost_index()
76
 
        reconciler = repo.reconcile(thorough=True)
77
 
        self.assertTrue(reconciler.aborted,
78
 
            "reconcile should have aborted due to bad parents.")
 
76
        result = repo.reconcile(thorough=True)
 
77
        self.assertTrue(result.aborted,
 
78
                        "reconcile should have aborted due to bad parents.")
79
79
 
80
80
    def test_does_not_abort_on_clean_repo(self):
81
81
        repo = self.make_repository('.')
82
 
        reconciler = repo.reconcile(thorough=True)
83
 
        self.assertFalse(reconciler.aborted,
84
 
            "reconcile should not have aborted on an unbroken repository.")
 
82
        result = repo.reconcile(thorough=True)
 
83
        self.assertFalse(result.aborted,
 
84
                         "reconcile should not have aborted on an unbroken repository.")
85
85
 
86
86
 
87
87
class TestsNeedingReweave(TestReconcile):
147
147
        self.make_repository('empty')
148
148
        d = BzrDir.open(self.get_url('empty'))
149
149
        # calling on a empty repository should do nothing
150
 
        reconciler = d.find_repository().reconcile(**kwargs)
 
150
        result = d.find_repository().reconcile(**kwargs)
151
151
        # no inconsistent parents should have been found
152
 
        self.assertEqual(0, reconciler.inconsistent_parents)
 
152
        self.assertEqual(0, result.inconsistent_parents)
153
153
        # and no garbage inventories
154
 
        self.assertEqual(0, reconciler.garbage_inventories)
 
154
        self.assertEqual(0, result.garbage_inventories)
155
155
        # and no backup weave should have been needed/made.
156
156
        self.checkNoBackupInventory(d)
157
157
 
187
187
        if not repo._reconcile_does_inventory_gc:
188
188
            raise TestSkipped('Irrelevant test')
189
189
        self.checkUnreconciled(d, repo.reconcile())
190
 
        reconciler = repo.reconcile(thorough=True)
 
190
        result = repo.reconcile(thorough=True)
191
191
        # no bad parents
192
 
        self.assertEqual(0, reconciler.inconsistent_parents)
 
192
        self.assertEqual(0, result.inconsistent_parents)
193
193
        # and one garbage inventory
194
 
        self.assertEqual(1, reconciler.garbage_inventories)
 
194
        self.assertEqual(1, result.garbage_inventories)
195
195
        self.check_missing_was_removed(repo)
196
196
 
197
197
    def check_thorough_reweave_missing_revision(self, aBzrDir, reconcile,
198
 
            **kwargs):
 
198
                                                **kwargs):
199
199
        # actual low level test.
200
200
        repo = aBzrDir.open_repository()
201
201
        if not repo.has_revision(b'missing'):
238
238
        d = BzrDir.open(d_url)
239
239
        if not d.open_repository()._reconcile_does_inventory_gc:
240
240
            raise TestSkipped('Irrelevant test')
 
241
 
241
242
        def reconcile():
242
243
            reconciler = Reconciler(d)
243
 
            reconciler.reconcile()
244
 
            return reconciler
 
244
            return reconciler.reconcile()
245
245
        self.check_thorough_reweave_missing_revision(d, reconcile)
246
246
 
247
247
    def test_reweave_inventory_without_revision_and_ghost(self):
254
254
        # nothing should have been altered yet : inventories without
255
255
        # revisions are not data loss incurring for current format
256
256
        self.check_thorough_reweave_missing_revision(d, repo.reconcile,
257
 
            thorough=True)
 
257
                                                     thorough=True)
258
258
 
259
259
    def test_reweave_inventory_preserves_a_revision_with_ghosts(self):
260
260
        d = BzrDir.open(self.get_url('inventory_one_ghost'))
267
267
        # now the current inventory should still have 'ghost'
268
268
        repo = d.open_repository()
269
269
        repo.get_inventory(b'ghost')
270
 
        self.assertThat([b'ghost', b'the_ghost'], MatchesAncestry(repo, b'ghost'))
 
270
        self.assertThat([b'ghost', b'the_ghost'],
 
271
                        MatchesAncestry(repo, b'ghost'))
271
272
 
272
273
    def test_reweave_inventory_fixes_ancestryfor_a_present_ghost(self):
273
274
        d = BzrDir.open(self.get_url('inventory_ghost_present'))
290
291
        repo.get_inventory(b'ghost')
291
292
        repo.get_inventory(b'the_ghost')
292
293
        self.assertThat([b'the_ghost', b'ghost'],
293
 
            MatchesAncestry(repo, b'ghost'))
 
294
                        MatchesAncestry(repo, b'ghost'))
294
295
        self.assertThat([b'the_ghost'],
295
 
            MatchesAncestry(repo, b'the_ghost'))
 
296
                        MatchesAncestry(repo, b'the_ghost'))
296
297
 
297
298
    def test_text_from_ghost_revision(self):
298
299
        repo = self.make_repository('text-from-ghost')
313
314
                repo.add_revision(b'final-revid', rev, inv)
314
315
                try:
315
316
                    repo.texts.add_lines((b'myfileid', b'ghostrevid'),
316
 
                        ((b'myfileid', b'ghost-text-parent'),),
317
 
                        [b"line1\n", b"line2\n"])
 
317
                                         ((b'myfileid', b'ghost-text-parent'),),
 
318
                                         [b"line1\n", b"line2\n"])
318
319
                except errors.RevisionNotPresent:
319
320
                    raise TestSkipped("text ghost parents not supported")
320
321
                if repo.supports_rich_root():
321
322
                    root_id = inv.root.file_id
322
323
                    repo.texts.add_lines((inv.root.file_id, inv.root.revision),
323
 
                        [], [])
 
324
                                         [], [])
324
325
            finally:
325
326
                repo.commit_write_group()
326
327
        repo.reconcile(thorough=True)
360
361
            t.commit('3', rev_id=b'3')
361
362
            uncommit(t.branch, tree=t)
362
363
        #second_tree = self.make_branch_and_tree('reversed-secondary-parents')
363
 
        #second_tree.pull(tree) # XXX won't copy the repo?
 
364
        # second_tree.pull(tree) # XXX won't copy the repo?
364
365
        repo_secondary = self.second_tree.branch.repository
365
366
 
366
367
        # now setup the wrong-first parent case
393
394
        if repo.supports_rich_root():
394
395
            root_id = inv.root.file_id
395
396
            repo.texts.add_lines((root_id, b'wrong-secondary-parent'), [], [])
396
 
        sha1 = repo.add_inventory(b'wrong-secondary-parent', inv, [b'1', b'3', b'2'])
 
397
        sha1 = repo.add_inventory(
 
398
            b'wrong-secondary-parent', inv, [b'1', b'3', b'2'])
397
399
        rev = Revision(timestamp=0,
398
400
                       timezone=None,
399
401
                       committer="Foo Bar <foo@example.com>",
412
414
        try:
413
415
            g = repo.get_graph()
414
416
            if g.get_parent_map([b'wrong-first-parent'])[b'wrong-first-parent'] \
415
 
                == (b'1', b'2'):
416
 
                raise TestSkipped('wrong-first-parent is not setup for testing')
 
417
                    == (b'1', b'2'):
 
418
                raise TestSkipped(
 
419
                    'wrong-first-parent is not setup for testing')
417
420
        finally:
418
421
            repo.unlock()
419
422
        self.checkUnreconciled(repo.controldir, repo.reconcile())
429
432
        self.addCleanup(repo.unlock)
430
433
        g = repo.get_graph()
431
434
        self.assertEqual(
432
 
            {b'wrong-first-parent':(b'1', b'2')},
 
435
            {b'wrong-first-parent': (b'1', b'2')},
433
436
            g.get_parent_map([b'wrong-first-parent']))
434
437
 
435
438
    def test_reconcile_wrong_order_secondary_inventory(self):