134
134
self.repo.control_weaves.copy(self.inventory, 'inventory.backup', self.repo.get_transaction())
135
135
self.pb.note('Backup Inventory created.')
136
136
# asking for '' should never return a non-empty weave
137
new_inventory = self.repo.control_weaves.get_empty('inventory.new',
137
new_inventory_vf = self.repo.control_weaves.get_empty('inventory.new',
138
138
self.repo.get_transaction())
140
140
# we have topological order of revisions and non ghost parents ready.
142
142
for rev_id in TopoSorter(self._rev_graph.items()).iter_topo_order():
143
143
parents = self._rev_graph[rev_id]
144
144
# double check this really is in topological order.
145
unavailable = [p for p in parents if p not in new_inventory]
145
unavailable = [p for p in parents if p not in new_inventory_vf]
146
146
assert len(unavailable) == 0
147
147
# this entry has all the non ghost parents in the inventory
149
149
self._reweave_step('adding inventories')
150
# ugly but needed, weaves are just way tooooo slow else.
151
if isinstance(new_inventory, WeaveFile):
152
Weave.add_lines(new_inventory, rev_id, parents, self.inventory.get_lines(rev_id))
150
if isinstance(new_inventory_vf, WeaveFile):
151
# It's really a WeaveFile, but we call straight into the
152
# Weave's add method to disable the auto-write-out behaviour.
153
new_inventory_vf._check_write_ok()
154
Weave._add_lines(new_inventory_vf, rev_id, parents, self.inventory.get_lines(rev_id),
154
new_inventory.add_lines(rev_id, parents, self.inventory.get_lines(rev_id))
157
new_inventory_vf.add_lines(rev_id, parents, self.inventory.get_lines(rev_id))
156
if isinstance(new_inventory, WeaveFile):
157
new_inventory._save()
158
# if this worked, the set of new_inventory.names should equal
159
if isinstance(new_inventory_vf, WeaveFile):
160
new_inventory_vf._save()
161
# if this worked, the set of new_inventory_vf.names should equal
160
assert set(new_inventory.versions()) == self.pending
163
assert set(new_inventory_vf.versions()) == self.pending
161
164
self.pb.update('Writing weave')
162
self.repo.control_weaves.copy(new_inventory, 'inventory', self.repo.get_transaction())
165
self.repo.control_weaves.copy(new_inventory_vf, 'inventory', self.repo.get_transaction())
163
166
self.repo.control_weaves.delete('inventory.new', self.repo.get_transaction())
164
167
self.inventory = None
165
168
self.pb.note('Inventory regenerated.')
258
261
self.repo.control_weaves.copy(self.inventory, 'inventory.backup', self.transaction)
259
262
self.pb.note('Backup Inventory created.')
260
263
# asking for '' should never return a non-empty weave
261
new_inventory = self.repo.control_weaves.get_empty('inventory.new',
264
new_inventory_vf = self.repo.control_weaves.get_empty('inventory.new',
262
265
self.transaction)
264
267
# we have topological order of revisions and non ghost parents ready.
266
269
for rev_id in TopoSorter(self.revisions.get_graph().items()).iter_topo_order():
267
270
parents = self.revisions.get_parents(rev_id)
268
271
# double check this really is in topological order.
269
unavailable = [p for p in parents if p not in new_inventory]
272
unavailable = [p for p in parents if p not in new_inventory_vf]
270
273
assert len(unavailable) == 0
271
274
# this entry has all the non ghost parents in the inventory
273
276
self._reweave_step('adding inventories')
274
277
# ugly but needed, weaves are just way tooooo slow else.
275
new_inventory.add_lines(rev_id, parents, self.inventory.get_lines(rev_id))
278
new_inventory_vf.add_lines(rev_id, parents, self.inventory.get_lines(rev_id))
277
# if this worked, the set of new_inventory.names should equal
280
# if this worked, the set of new_inventory_vf.names should equal
279
assert set(new_inventory.versions()) == set(self.revisions.versions())
282
assert set(new_inventory_vf.versions()) == set(self.revisions.versions())
280
283
self.pb.update('Writing weave')
281
self.repo.control_weaves.copy(new_inventory, 'inventory', self.transaction)
284
self.repo.control_weaves.copy(new_inventory_vf, 'inventory', self.transaction)
282
285
self.repo.control_weaves.delete('inventory.new', self.transaction)
283
286
self.inventory = None
284
287
self.pb.note('Inventory regenerated.')