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, [])
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)
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')
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)
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)
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)
133
146
def check_thorough_reweave_missing_revision(self, aBzrDir, reconcile,
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'))
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')
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')
168
183
reconciler = Reconciler(d)
169
184
reconciler.reconcile()
170
185
return reconciler
171
186
self.check_thorough_reweave_missing_revision(d, reconcile)
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,
204
218
self.assertEqual([None, 'ghost'], ghost_ancestry)
205
219
reconciler = repo.reconcile()
206
self.checkUnreconciled(d, reconciler)
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)