/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
        # TODO: make sure to construct the right store classes, etc, depending
168
168
        # on whether escaping is required.
169
169
 
 
170
    def __repr__(self):
 
171
        return '%s(%r)' % (self.__class__.__name__, 
 
172
                           self.bzrdir.transport.base)
 
173
 
170
174
    def is_locked(self):
171
175
        return self.control_files.is_locked()
172
176
 
605
609
        return True
606
610
 
607
611
 
 
612
def install_revision(repository, rev, revision_tree):
 
613
    """Install all revision data into a repository."""
 
614
    present_parents = []
 
615
    parent_trees = {}
 
616
    for p_id in rev.parent_ids:
 
617
        if repository.has_revision(p_id):
 
618
            present_parents.append(p_id)
 
619
            parent_trees[p_id] = repository.revision_tree(p_id)
 
620
        else:
 
621
            parent_trees[p_id] = EmptyTree()
 
622
 
 
623
    inv = revision_tree.inventory
 
624
    
 
625
    # Add the texts that are not already present
 
626
    for path, ie in inv.iter_entries():
 
627
        w = repository.weave_store.get_weave_or_empty(ie.file_id,
 
628
                repository.get_transaction())
 
629
        if ie.revision not in w:
 
630
            text_parents = []
 
631
            for revision, tree in parent_trees.iteritems():
 
632
                if ie.file_id not in tree:
 
633
                    continue
 
634
                parent_id = tree.inventory[ie.file_id].revision
 
635
                if parent_id in text_parents:
 
636
                    continue
 
637
                text_parents.append(parent_id)
 
638
                    
 
639
            vfile = repository.weave_store.get_weave_or_empty(ie.file_id, 
 
640
                repository.get_transaction())
 
641
            lines = revision_tree.get_file(ie.file_id).readlines()
 
642
            vfile.add_lines(rev.revision_id, text_parents, lines)
 
643
    try:
 
644
        # install the inventory
 
645
        repository.add_inventory(rev.revision_id, inv, present_parents)
 
646
    except errors.RevisionAlreadyPresent:
 
647
        pass
 
648
    repository.add_revision(rev.revision_id, rev, inv)
 
649
 
 
650
 
608
651
class MetaDirRepository(Repository):
609
652
    """Repositories in the new meta-dir layout."""
610
653
 
1452
1495
        target_ids = set(self.target.all_revision_ids())
1453
1496
        if revision_id is not None:
1454
1497
            source_ids = self.source.get_ancestry(revision_id)
1455
 
            assert source_ids.pop(0) == None
 
1498
            assert source_ids[0] == None
 
1499
            source_ids.pop(0)
1456
1500
        else:
1457
1501
            source_ids = self.source.all_revision_ids()
1458
1502
        result_set = set(source_ids).difference(target_ids)
1561
1605
        # - RBC 20060209
1562
1606
        if revision_id is not None:
1563
1607
            source_ids = self.source.get_ancestry(revision_id)
1564
 
            assert source_ids.pop(0) == None
 
1608
            assert source_ids[0] == None
 
1609
            source_ids.pop(0)
1565
1610
        else:
1566
1611
            source_ids = self.source._all_possible_ids()
1567
1612
        source_ids_set = set(source_ids)
1623
1668
        """See InterRepository.missing_revision_ids()."""
1624
1669
        if revision_id is not None:
1625
1670
            source_ids = self.source.get_ancestry(revision_id)
1626
 
            assert source_ids.pop(0) == None
 
1671
            assert source_ids[0] == None
 
1672
            source_ids.pop(0)
1627
1673
        else:
1628
1674
            source_ids = self.source._all_possible_ids()
1629
1675
        source_ids_set = set(source_ids)