~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Andrew Bennetts
  • Date: 2007-07-17 06:07:00 UTC
  • mto: (2535.4.4 streaming-smart-fetch)
  • mto: This revision was merged to the branch mainline in revision 2906.
  • Revision ID: andrew.bennetts@canonical.com-20070717060700-blzcnto7drjgc7yc
[broken] Closer to a working Repository.fetch_revisions smart request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
from bzrlib.lazy_import import lazy_import
48
48
 
 
49
lazy_import(globals(), """
 
50
from bzrlib import remote
 
51
""")
 
52
 
49
53
# TODO: Avoid repeatedly opening weaves so many times.
50
54
 
51
55
# XXX: This doesn't handle ghost (not present in branch) revisions at
89
93
        # result variables.
90
94
        self.failed_revisions = []
91
95
        self.count_copied = 0
92
 
        if to_repository.control_files._transport.base == from_repository.control_files._transport.base:
93
 
            # check that last_revision is in 'from' and then return a no-operation.
94
 
            if last_revision not in (None, NULL_REVISION):
95
 
                from_repository.get_revision(last_revision)
 
96
        if self._same_repo(to_repository, from_repository, last_revision):
96
97
            return
97
98
        self.to_repository = to_repository
98
99
        self.from_repository = from_repository
116
117
        finally:
117
118
            self.from_repository.unlock()
118
119
 
 
120
    def _same_repo(self, to_repository, from_repository, last_revision):
 
121
        if to_repository.control_files._transport.base == from_repository.control_files._transport.base:
 
122
            # check that last_revision is in 'from' and then return a no-operation.
 
123
            if last_revision not in (None, NULL_REVISION):
 
124
                from_repository.get_revision(last_revision)
 
125
            return True
 
126
        return False
 
127
 
119
128
    def __fetch(self):
120
129
        """Primary worker function.
121
130
 
407
416
    def _fetch_everything_for_revisions(self, revs, pp):
408
417
        # XXX: this assumes that we want RemoteRepository.get_data_stream to
409
418
        # deserialise the smart response.
410
 
        data_stream = self.from_repository.get_data_stream(revs, pp)
 
419
        data_stream = self.from_repository.get_data_stream(revs)
411
420
        self.to_repository.insert_data_stream(data_stream)
412
421
 
 
422
    def _same_repo(self, to_repository, from_repository, last_revision):
 
423
        assert isinstance(from_repository, remote.RemoteRepository), from_repository
 
424
        if isinstance(to_repository, remote.RemoteRepository):
 
425
            return to_repository._client is from_repository._client
 
426
        else:
 
427
            return False
 
428
 
413
429
 
414
430
class Fetcher(object):
415
431
    """Backwards compatibility glue for branch.fetch()."""