1452
1452
[parents_provider, other_repository._make_parents_provider()])
1453
1453
return graph.Graph(parents_provider)
1455
def get_versioned_file_checker(self, revisions, revision_versions_cache):
1456
return WeaveChecker(revisions, revision_versions_cache, self)
1455
1458
def find_bad_ancestors(self, revision_ids, file_id, versionedfile,
1456
1459
revision_versions):
1457
1460
"""Search the versionedfile for ancestors that are not referenced.
2524
2527
self._memoized[revision_id] = parents
2525
2528
parents_list.append(parents)
2526
2529
return parents_list
2532
class WeaveChecker(object):
2534
def __init__(self, planned_revisions, revision_versions, repository):
2535
self.planned_revisions = planned_revisions
2536
self.revision_versions = revision_versions
2537
self.repository = repository
2539
def calculate_file_version_parents(self, revision_id, file_id,
2541
text_revision = self.revision_versions.get_text_version(
2542
file_id, revision_id)
2543
if text_revision is None:
2545
parents_of_text_revision = parents_provider.get_parents(
2547
parents_from_inventories = []
2548
for parent in parents_of_text_revision:
2549
if parent == _mod_revision.NULL_REVISION:
2552
inventory = self.repository.get_inventory(parent)
2553
except errors.RevisionNotPresent:
2556
introduced_in = inventory[file_id].revision
2557
parents_from_inventories.append(introduced_in)
2558
mutter('%r:%r introduced in: %r',
2559
file_id, revision_id, parents_from_inventories)
2560
graph = self.repository.get_graph()
2561
heads = set(graph.heads(parents_from_inventories))
2562
mutter(' heads: %r', heads)
2564
for parent in parents_from_inventories:
2565
if parent in heads and parent not in new_parents:
2566
new_parents.append(parent)
2569
def check_file_version_parents(self, weave, file_id, parents_provider):
2571
for num, revision_id in enumerate(self.planned_revisions):
2572
correct_parents = self.calculate_file_version_parents(
2573
revision_id, file_id, parents_provider)
2574
if correct_parents is None:
2576
text_revision = self.revision_versions.get_text_version(
2577
file_id, revision_id)
2578
knit_parents = weave.get_parents(text_revision)
2579
if correct_parents != knit_parents:
2580
result[revision_id] = (knit_parents, correct_parents)