~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: Andrew Bennetts
  • Date: 2007-10-05 00:44:53 UTC
  • mto: This revision was merged to the branch mainline in revision 2905.
  • Revision ID: andrew.bennetts@canonical.com-20071005004453-01gpk6nnh4zelciv
Move check_parents out of VersionedFile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
                    b_marker=TextMerge.B_MARKER):
497
497
        return PlanWeaveMerge(plan, a_marker, b_marker).merge_lines()[0]
498
498
 
499
 
    def calculate_parents(self, revision_id, get_text_version, file_id,
500
 
            parents_provider, repo_graph, get_inventory):
501
 
        text_revision = get_text_version(file_id, revision_id)
502
 
        if text_revision is None:
503
 
            return None
504
 
        parents_of_text_revision = parents_provider.get_parents(
505
 
            [text_revision])[0]
506
 
        parents_from_inventories = []
507
 
        for parent in parents_of_text_revision:
508
 
            if parent == revision.NULL_REVISION:
509
 
                continue
510
 
            try:
511
 
                inventory = get_inventory(parent)
512
 
            except errors.RevisionNotPresent:
513
 
                pass
514
 
            else:
515
 
                introduced_in = inventory[file_id].revision
516
 
                parents_from_inventories.append(introduced_in)
517
 
        mutter('%r:%r introduced in: %r',
518
 
               file_id, revision_id, parents_from_inventories)
519
 
        heads = set(repo_graph.heads(parents_from_inventories))
520
 
        mutter('    heads: %r', heads)
521
 
        new_parents = []
522
 
        for parent in parents_from_inventories:
523
 
            if parent in heads and parent not in new_parents:
524
 
                new_parents.append(parent)
525
 
        return new_parents
526
 
 
527
 
    def check_parents(self, revision_ids, get_text_version, file_id,
528
 
            parents_provider, repo_graph, get_inventory):
529
 
        result = {}
530
 
        for num, revision_id in enumerate(revision_ids):
531
 
            correct_parents = self.calculate_parents(revision_id,
532
 
                    get_text_version, file_id, parents_provider, repo_graph,
533
 
                    get_inventory)
534
 
            if correct_parents is None:
535
 
                continue
536
 
            text_revision = get_text_version(file_id, revision_id)
537
 
            knit_parents = self.get_parents(text_revision)
538
 
            if correct_parents != knit_parents:
539
 
                result[revision_id] = (knit_parents, correct_parents)
540
 
        mutter('    RESULT: %r', result)
541
 
        return result
542
 
 
543
499
    def find_bad_ancestors(self, revision_ids, get_text_version, file_id,
544
500
            parents_provider, repo_graph):
545
501
        """Search this versionedfile for ancestors that are not referenced.