~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-06-03 20:18:35 UTC
  • mfrom: (1185.82.137 w-changeset)
  • Revision ID: pqm@pqm.ubuntu.com-20060603201835-1c9a1725641ccd24
Implement bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
616
616
        return True
617
617
 
618
618
 
 
619
def install_revision(repository, rev, revision_tree):
 
620
    """Install all revision data into a repository."""
 
621
    present_parents = []
 
622
    parent_trees = {}
 
623
    for p_id in rev.parent_ids:
 
624
        if repository.has_revision(p_id):
 
625
            present_parents.append(p_id)
 
626
            parent_trees[p_id] = repository.revision_tree(p_id)
 
627
        else:
 
628
            parent_trees[p_id] = EmptyTree()
 
629
 
 
630
    inv = revision_tree.inventory
 
631
    
 
632
    # Add the texts that are not already present
 
633
    for path, ie in inv.iter_entries():
 
634
        w = repository.weave_store.get_weave_or_empty(ie.file_id,
 
635
                repository.get_transaction())
 
636
        if ie.revision not in w:
 
637
            text_parents = []
 
638
            for revision, tree in parent_trees.iteritems():
 
639
                if ie.file_id not in tree:
 
640
                    continue
 
641
                parent_id = tree.inventory[ie.file_id].revision
 
642
                if parent_id in text_parents:
 
643
                    continue
 
644
                text_parents.append(parent_id)
 
645
                    
 
646
            vfile = repository.weave_store.get_weave_or_empty(ie.file_id, 
 
647
                repository.get_transaction())
 
648
            lines = revision_tree.get_file(ie.file_id).readlines()
 
649
            vfile.add_lines(rev.revision_id, text_parents, lines)
 
650
    try:
 
651
        # install the inventory
 
652
        repository.add_inventory(rev.revision_id, inv, present_parents)
 
653
    except errors.RevisionAlreadyPresent:
 
654
        pass
 
655
    repository.add_revision(rev.revision_id, rev, inv)
 
656
 
 
657
 
619
658
class MetaDirRepository(Repository):
620
659
    """Repositories in the new meta-dir layout."""
621
660