~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
        finally:
287
287
            destination.unlock()
288
288
 
289
 
    @needs_write_lock
290
 
    def fetch(self, source, revision_id=None):
 
289
    def fetch(self, source, revision_id=None, pb=None):
291
290
        """Fetch the content required to construct revision_id from source.
292
291
 
293
292
        If revision_id is None all content is copied.
294
293
        """
295
 
        from bzrlib.fetch import RepoFetcher
296
 
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
297
 
               source, source._format, self, self._format)
298
 
        RepoFetcher(to_repository=self, from_repository=source, last_revision=revision_id)
 
294
        return InterRepository.get(source, self).fetch(revision_id=revision_id,
 
295
                                                       pb=pb)
299
296
 
300
297
    def unlock(self):
301
298
        self.control_files.unlock()
907
904
        self.source = source
908
905
        self.target = target
909
906
 
 
907
    def fetch(self, revision_id=None, pb=None):
 
908
        """Fetch the content required to construct revision_id.
 
909
 
 
910
        The content is copied from source to target.
 
911
 
 
912
        :param revision_id: if None all content is copied, if NULL_REVISION no
 
913
                            content is copied.
 
914
        :param pb: optional progress bar to use for progress reports. If not
 
915
                   provided a default one will be created.
 
916
 
 
917
        Returns the copied revision count and the failed revisions in a tuple:
 
918
        (copied, failures).
 
919
        """
 
920
        from bzrlib.fetch import RepoFetcher
 
921
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
 
922
               self.source, self.source._format, self.target, self.target._format)
 
923
        self.target.lock_write()
 
924
        try:
 
925
            f = RepoFetcher(to_repository=self.target,
 
926
                            from_repository=self.source,
 
927
                            last_revision=revision_id,
 
928
                            pb=pb)
 
929
            return f.count_copied, f.failed_revisions
 
930
        finally:
 
931
            self.target.unlock()
 
932
 
910
933
    @classmethod
911
934
    def get(klass, repository_source, repository_target):
912
935
        """Retrieve a InterRepository worker object for these repositories.
934
957
        klass._optimisers.remove(optimiser)
935
958
 
936
959
 
 
960
class InterWeaveRepo(InterRepository):
 
961
    """Optimised code paths between Weave based repositories."""
 
962
 
 
963
    @staticmethod
 
964
    def is_compatible(source, target):
 
965
        """Be compatible with known Weave formats.
 
966
        
 
967
        We dont test for the stores being of specific types becase that
 
968
        could lead to confusing results, and there is no need to be 
 
969
        overly general.
 
970
        """
 
971
 
 
972
    def fetch(self, revision_id=None, pb=None):
 
973
        """See InterRepository.fetch()."""
 
974
        from bzrlib.fetch import RepoFetcher
 
975
        mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
 
976
               self.source, self.source._format, self.target, self.target._format)
 
977
        self.target.lock_write()
 
978
        try:
 
979
            f = RepoFetcher(to_repository=self.target,
 
980
                            from_repository=self.source,
 
981
                            last_revision=revision_id,
 
982
                            pb=pb)
 
983
            return f.count_copied, f.failed_revisions
 
984
        finally:
 
985
            self.target.unlock()
 
986
 
 
987
 
937
988
class RepositoryTestProviderAdapter(object):
938
989
    """A tool to generate a suite testing multiple repository formats at once.
939
990