~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin Pool
  • Date: 2008-05-02 02:31:14 UTC
  • mfrom: (3399 +trunk)
  • mto: (3408.1.1 doc)
  • mto: This revision was merged to the branch mainline in revision 3409.
  • Revision ID: mbp@sourcefrog.net-20080502023114-y2gcg3w3jc770j9m
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
542
542
            plaintext = Testament(rev, inv).as_short_text()
543
543
            self.store_revision_signature(
544
544
                gpg.GPGStrategy(config), plaintext, revision_id)
545
 
        if not revision_id in self.get_inventory_weave():
 
545
        inventory_vf = self.get_inventory_weave()
 
546
        if not revision_id in inventory_vf:
546
547
            if inv is None:
547
548
                raise errors.WeaveRevisionNotPresent(revision_id,
548
 
                                                     self.get_inventory_weave())
 
549
                                                     inventory_vf)
549
550
            else:
550
551
                # yes, this is not suitable for adding with ghosts.
551
 
                rev.inventory_sha1 = self.add_inventory(revision_id, inv, 
 
552
                rev.inventory_sha1 = self.add_inventory(revision_id, inv,
552
553
                                                        rev.parent_ids)
 
554
        else:
 
555
            rev.inventory_sha1 = inventory_vf.get_sha1s([revision_id])[0]
553
556
        self._revision_store.add_revision(rev, self.get_transaction())
554
557
 
555
558
    def _add_revision_text(self, revision_id, text):
2380
2383
        :param revision_ids: The start point for the search.
2381
2384
        :return: A set of revision ids.
2382
2385
        """
2383
 
        graph = self.source.get_graph()
2384
2386
        target_graph = self.target.get_graph()
 
2387
        revision_ids = frozenset(revision_ids)
 
2388
        if set(target_graph.get_parent_map(revision_ids)) == revision_ids:
 
2389
            return graph.SearchResult(revision_ids, set(), 0, set())
2385
2390
        missing_revs = set()
 
2391
        source_graph = self.source.get_graph()
2386
2392
        # ensure we don't pay silly lookup costs.
2387
 
        revision_ids = frozenset(revision_ids)
2388
 
        searcher = graph._make_breadth_first_searcher(revision_ids)
 
2393
        searcher = source_graph._make_breadth_first_searcher(revision_ids)
2389
2394
        null_set = frozenset([_mod_revision.NULL_REVISION])
2390
2395
        while True:
2391
2396
            try:
2742
2747
            # inventory parsing etc, IFF nothing to be copied is in the target.
2743
2748
            # till then:
2744
2749
            revision_ids = self.source.all_revision_ids()
 
2750
            revision_keys = [(revid,) for revid in revision_ids]
 
2751
            index = self.target._pack_collection.revision_index.combined_index
 
2752
            present_revision_ids = set(item[1][0] for item in
 
2753
                index.iter_entries(revision_keys))
 
2754
            revision_ids = set(revision_ids) - present_revision_ids
2745
2755
            # implementing the TODO will involve:
2746
2756
            # - detecting when all of a pack is selected
2747
2757
            # - avoiding as much as possible pre-selection, so the
2758
2768
                    find_ghosts=find_ghosts).get_keys()
2759
2769
            except errors.NoSuchRevision:
2760
2770
                raise errors.InstallFailed([revision_id])
 
2771
            if len(revision_ids) == 0:
 
2772
                return (0, [])
2761
2773
        packs = self.source._pack_collection.all_packs()
2762
2774
        pack = Packer(self.target._pack_collection, packs, '.fetch',
2763
2775
            revision_ids).pack()