~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-05-03 09:25:40 UTC
  • mto: (1692.4.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1694.
  • Revision ID: robertc@robertcollins.net-20060503092540-9f4487ad389bc285
Finish the reconcile tweak: filled in ghosts are a data loss issue and need to be checked during fast reconciles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
        
56
56
        t = get_transport(self.get_url())
57
57
        # an empty inventory with no revision for testing with.
 
58
        repo = self.make_repository('inventory_without_revision')
 
59
        inv = EmptyTree().inventory
 
60
        repo.add_inventory('missing', inv, [])
 
61
 
 
62
        # an empty inventory with no revision for testing with.
58
63
        # this is referenced by 'references_missing' to let us test
59
64
        # that all the cached data is correctly converted into ghost links
60
65
        # and the referenced inventory still cleaned.
61
 
        repo = self.make_repository('inventory_without_revision')
 
66
        repo = self.make_repository('inventory_without_revision_and_ghost')
62
67
        inv = EmptyTree().inventory
63
68
        repo.add_inventory('missing', inv, [])
64
69
        sha1 = repo.add_inventory('references_missing', inv, ['missing'])
118
123
        # reconcile should accept thorough=True
119
124
        self.checkEmptyReconcile(thorough=True)
120
125
 
121
 
    def test_reweave_inventory_without_revision_reconcile(self):
 
126
    def test_convenience_reconcile_inventory_without_revision_reconcile(self):
122
127
        # smoke test for the all in one ui tool
123
128
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
124
129
        reconcile(d)
125
130
        # now the backup should have it but not the current inventory
126
131
        repo = d.open_repository()
127
 
        backup = repo.control_weaves.get_weave('inventory.backup',
128
 
                                               repo.get_transaction())
129
 
        self.assertTrue('missing' in backup.versions())
130
 
        self.assertRaises(errors.RevisionNotPresent,
131
 
                          repo.get_inventory, 'missing')
 
132
        self.check_missing_was_removed(repo)
 
133
 
 
134
    def test_reweave_inventory_without_revision(self):
 
135
        # an excess inventory on its own is only reconciled by using thorough
 
136
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
 
137
        repo = d.open_repository()
 
138
        self.checkUnreconciled(d, repo.reconcile())
 
139
        reconciler = repo.reconcile(thorough=True)
 
140
        # no bad parents
 
141
        self.assertEqual(0, reconciler.inconsistent_parents)
 
142
        # and one garbage inventoriy
 
143
        self.assertEqual(1, reconciler.garbage_inventories)
 
144
        self.check_missing_was_removed(repo)
132
145
 
133
146
    def check_thorough_reweave_missing_revision(self, aBzrDir, reconcile,
134
147
            **kwargs):
135
148
        # actual low level test.
136
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
137
149
        repo = aBzrDir.open_repository()
138
150
        if ([None, 'missing', 'references_missing'] 
139
151
            != repo.get_ancestry('references_missing')):
150
162
        self.assertEqual(1, reconciler.garbage_inventories)
151
163
        # now the backup should have it but not the current inventory
152
164
        repo = aBzrDir.open_repository()
153
 
        backup = repo.control_weaves.get_weave('inventory.backup',
154
 
                                               repo.get_transaction())
155
 
        self.assertTrue('missing' in backup.versions())
156
 
        self.assertRaises(errors.RevisionNotPresent,
157
 
                          repo.get_inventory, 'missing')
 
165
        self.check_missing_was_removed(repo)
158
166
        # and the parent list for 'references_missing' should have that
159
167
        # revision a ghost now.
160
168
        self.assertEqual([None, 'references_missing'],
161
169
                         repo.get_ancestry('references_missing'))
162
170
 
 
171
    def check_missing_was_removed(self, repo):
 
172
        backup = repo.control_weaves.get_weave('inventory.backup',
 
173
                                               repo.get_transaction())
 
174
        self.assertTrue('missing' in backup.versions())
 
175
        self.assertRaises(errors.RevisionNotPresent,
 
176
                          repo.get_inventory, 'missing')
 
177
 
163
178
    def test_reweave_inventory_without_revision_reconciler(self):
164
179
        # smoke test for the all in one Reconciler class,
165
180
        # other tests use the lower level repo.reconcile()
166
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
 
181
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision_and_ghost')
167
182
        def reconcile():
168
183
            reconciler = Reconciler(d)
169
184
            reconciler.reconcile()
170
185
            return reconciler
171
186
        self.check_thorough_reweave_missing_revision(d, reconcile)
172
187
 
173
 
    def test_reweave_inventory_without_revision(self):
 
188
    def test_reweave_inventory_without_revision_and_ghost(self):
174
189
        # actual low level test.
175
 
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision')
 
190
        d = bzrlib.bzrdir.BzrDir.open('inventory_without_revision_and_ghost')
176
191
        repo = d.open_repository()
177
 
        self.checkUnreconciled(d, repo.reconcile())
178
192
        # nothing should have been altered yet : inventories without
179
193
        # revisions are not data loss incurring for current format
180
194
        self.check_thorough_reweave_missing_revision(d, repo.reconcile,
203
217
            return
204
218
        self.assertEqual([None, 'ghost'], ghost_ancestry)
205
219
        reconciler = repo.reconcile()
206
 
        self.checkUnreconciled(d, reconciler)
207
 
 
208
 
        reconciler = repo.reconcile(thorough=True)
 
220
        # this is a data corrupting error, so a normal reconcile should fix it.
209
221
        # one inconsistent parents should have been found : the
210
222
        # available but not reference parent for ghost.
211
223
        self.assertEqual(1, reconciler.inconsistent_parents)