336
341
self.garbage_inventories = len(garbage)
337
342
for revision_id in garbage:
338
343
mutter('Garbage inventory {%s} found.', revision_id)
345
def _fix_text_parents(self):
346
transaction = self.repo.get_transaction()
347
revision_parents = repository._RevisionParentsProvider(self.repo)
348
revision_graph = graph.Graph(revision_parents)
349
revision_versions = {}
350
for file_id in self.repo.weave_store:
351
vf = self.repo.weave_store.get_weave(file_id, transaction)
352
bad_ancestors = self.repo.find_bad_ancestors(
353
self.revisions.versions(), file_id, vf, revision_versions,
355
if len(bad_ancestors) == 0:
357
new_vf = self.repo.weave_store.get_empty('temp:%s' % file_id,
359
for version in vf.versions():
360
parents = vf.get_parents(version)
361
for parent_id in parents:
362
if (parent_id in bad_ancestors and
363
version in bad_ancestors[parent_id]):
364
parents = self._find_correct_parents(version,
365
file_id, revision_versions, revision_graph)
367
new_vf.add_lines(version, parents, vf.get_lines(version))
368
self.repo.weave_store.copy(new_vf, file_id, self.transaction)
369
self.repo.weave_store.delete('temp:%s' % file_id, self.transaction)
371
def _find_correct_parents(self, revision_id, file_id, revision_versions,
374
rev_parents = revision_graph.get_parents([revision_id])[0]
375
if rev_parents is None:
377
for parent_id in rev_parents:
379
parent_id = revision_versions[parent_id][file_id]
382
if parent_id not in parents:
383
parents.append(parent_id)
385
for num, parent in enumerate(parents):
386
for other_parent in parents[num+1:]:
387
if revision_graph.is_ancestor(parent, other_parent):
388
non_heads.add(parent)
389
if revision_graph.is_ancestor(other_parent, parent):
390
non_heads.add(other_parent)
391
return [p for p in parents if p not in non_heads]