~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2008-01-11 07:12:15 UTC
  • mfrom: (3172.4.1 more-find-ghosts)
  • mto: This revision was merged to the branch mainline in revision 3184.
  • Revision ID: robertc@robertcollins.net-20080111071215-n51r2omrs3e7216m
Merge more-find-ghosts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2312
2312
 
2313
2313
        :param revision_id: only return revision ids included by this
2314
2314
                            revision_id.
 
2315
        :param find_ghosts: If True find missing revisions in deep history
 
2316
            rather than just finding the surface difference.
2315
2317
        """
 
2318
        # stop searching at found target revisions.
 
2319
        if not find_ghosts and revision_id is not None:
 
2320
            graph = self.source.get_graph()
 
2321
            missing_revs = set()
 
2322
            searcher = graph._make_breadth_first_searcher([revision_id])
 
2323
            null_set = frozenset([_mod_revision.NULL_REVISION])
 
2324
            while True:
 
2325
                try:
 
2326
                    next_revs = set(searcher.next())
 
2327
                except StopIteration:
 
2328
                    break
 
2329
                next_revs.difference_update(null_set)
 
2330
                have_revs = self.target.has_revisions(next_revs)
 
2331
                missing_revs.update(next_revs - have_revs)
 
2332
                searcher.stop_searching_any(have_revs)
 
2333
            if next_revs - have_revs == set([revision_id]):
 
2334
                # we saw the start rev itself, but no parents from it (or
 
2335
                # next_revs would have been updated to e.g. set(). We remove
 
2336
                # have_revs because if we found revision_id locally we
 
2337
                # stop_searching at the first time around.
 
2338
                raise errors.NoSuchRevision(self.source, revision_id)
 
2339
            return missing_revs
2316
2340
        # generic, possibly worst case, slow code path.
2317
2341
        target_ids = set(self.target.all_revision_ids())
2318
2342
        if revision_id is not None:
2390
2414
        f = GenericRepoFetcher(to_repository=self.target,
2391
2415
                               from_repository=self.source,
2392
2416
                               last_revision=revision_id,
2393
 
                               pb=pb)
 
2417
                               pb=pb, find_ghosts=find_ghosts)
2394
2418
        return f.count_copied, f.failed_revisions
2395
2419
 
2396
2420
 
2468
2492
        f = GenericRepoFetcher(to_repository=self.target,
2469
2493
                               from_repository=self.source,
2470
2494
                               last_revision=revision_id,
2471
 
                               pb=pb)
 
2495
                               pb=pb, find_ghosts=find_ghosts)
2472
2496
        return f.count_copied, f.failed_revisions
2473
2497
 
2474
2498
    @needs_read_lock
2546
2570
        f = KnitRepoFetcher(to_repository=self.target,
2547
2571
                            from_repository=self.source,
2548
2572
                            last_revision=revision_id,
2549
 
                            pb=pb)
 
2573
                            pb=pb, find_ghosts=find_ghosts)
2550
2574
        return f.count_copied, f.failed_revisions
2551
2575
 
2552
2576
    @needs_read_lock
2651
2675
    def missing_revision_ids(self, revision_id=None, find_ghosts=True):
2652
2676
        """See InterRepository.missing_revision_ids().
2653
2677
        
2654
 
        :param find_ghosts: Find ghosts throughough the ancestry of
 
2678
        :param find_ghosts: Find ghosts throughout the ancestry of
2655
2679
            revision_id.
2656
2680
        """
2657
2681
        if not find_ghosts and revision_id is not None:
2709
2733
        f = Model1toKnit2Fetcher(to_repository=self.target,
2710
2734
                                 from_repository=self.source,
2711
2735
                                 last_revision=revision_id,
2712
 
                                 pb=pb)
 
2736
                                 pb=pb, find_ghosts=find_ghosts)
2713
2737
        return f.count_copied, f.failed_revisions
2714
2738
 
2715
2739
    @needs_write_lock
2766
2790
        f = Knit1to2Fetcher(to_repository=self.target,
2767
2791
                            from_repository=self.source,
2768
2792
                            last_revision=revision_id,
2769
 
                            pb=pb)
 
2793
                            pb=pb, find_ghosts=find_ghosts)
2770
2794
        return f.count_copied, f.failed_revisions
2771
2795
 
2772
2796
 
2792
2816
    def fetch(self, revision_id=None, pb=None, find_ghosts=False):
2793
2817
        """See InterRepository.fetch()."""
2794
2818
        revision_ids = self.target.missing_revision_ids(self.source,
2795
 
                                                        revision_id)
 
2819
            revision_id, find_ghosts=find_ghosts)
2796
2820
        def revisions_iterator():
2797
2821
            for current_revision_id in revision_ids:
2798
2822
                revision = self.source.get_revision(current_revision_id)
2847
2871
        f = RemoteToOtherFetcher(to_repository=self.target,
2848
2872
                                 from_repository=self.source,
2849
2873
                                 last_revision=revision_id,
2850
 
                                 pb=pb)
 
2874
                                 pb=pb, find_ghosts=find_ghosts)
2851
2875
        return f.count_copied, f.failed_revisions
2852
2876
 
2853
2877
    @classmethod
2879
2903
 
2880
2904
    def fetch(self, revision_id=None, pb=None, find_ghosts=False):
2881
2905
        self._ensure_real_inter()
2882
 
        self._real_inter.fetch(revision_id=revision_id, pb=pb)
 
2906
        self._real_inter.fetch(revision_id=revision_id, pb=pb,
 
2907
            find_ghosts=find_ghosts)
2883
2908
 
2884
2909
    @classmethod
2885
2910
    def _get_repo_format_to_test(self):