/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: 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:
55
55
        zero_nine,
56
56
        )
57
57
from bzrlib.trace import mutter, note, warning
 
58
from bzrlib.util import bencode
58
59
 
59
60
 
60
61
# Old formats display a warning, but only once
326
327
    def get_data_stream(self, revision_ids):
327
328
        raise NotImplementedError(self.get_data_stream)
328
329
 
 
330
    def insert_data_stream(self, stream):
 
331
        for knit_name, bytes in stream:
 
332
            #bytes_buffer = StringIO(bytes)
 
333
            if knit_name.startswith('file:'):
 
334
                file_id = knit_name[5:]
 
335
                knit = self.text_store.get_weave_or_empty(
 
336
                    file_id, self.get_transaction())
 
337
            elif knit_name == 'inventory':
 
338
                knit = self.get_inventory_weave()
 
339
            elif knit_name == 'revisions':
 
340
                knit = self.control_weaves.get_weave(
 
341
                    'revisions', self.get_transaction())
 
342
            else:
 
343
                raise 'boom', knit_name # XXX
 
344
            decoded_list = bencode.bdecode(bytes)
 
345
            format = decoded_list.pop(0)
 
346
            data_list = []
 
347
            knit_bytes = ''
 
348
            for version, options, parents, some_bytes in decoded_list:
 
349
                data_list.append((version, options, len(some_bytes), parents))
 
350
                knit_bytes += some_bytes
 
351
            knit.insert_data_stream((format, data_list,
 
352
                StringIO(knit_bytes).read))
 
353
            #assert bytes_buffer.tell() == len(bytes)
 
354
 
 
355
 
329
356
    @needs_read_lock
330
357
    def missing_revision_ids(self, other, revision_id=None):
331
358
        """Return the revision ids that other has that this does not.
1817
1844
    @needs_write_lock
1818
1845
    def fetch(self, revision_id=None, pb=None):
1819
1846
        """See InterRepository.fetch()."""
1820
 
        self._ensure_real_inter()
1821
 
        self._real_inter.fetch(revision_id=revision_id, pb=pb)
1822
 
#        from bzrlib.fetch import RemoteToOtherFetcher
1823
 
#        mutter("Using fetch logic to copy between %s(remote) and %s(%s)",
1824
 
#               self.source, self.target, self.target._format)
1825
 
#        # TODO: jam 20070210 This should be an assert, not a translate
1826
 
#        revision_id = osutils.safe_revision_id(revision_id)
1827
 
#        f = RemoteToOtherFetcher(to_repository=self.target,
1828
 
#                                 from_repository=self.source,
1829
 
#                                 last_revision=revision_id,
1830
 
#                                 pb=pb)
1831
 
#        return f.count_copied, f.failed_revisions
 
1847
        #self._ensure_real_inter()
 
1848
        #self._real_inter.fetch(revision_id=revision_id, pb=pb)
 
1849
        from bzrlib.fetch import RemoteToOtherFetcher
 
1850
        mutter("Using fetch logic to copy between %s(remote) and %s(%s)",
 
1851
               self.source, self.target, self.target._format)
 
1852
        # TODO: jam 20070210 This should be an assert, not a translate
 
1853
        revision_id = osutils.safe_revision_id(revision_id)
 
1854
        f = RemoteToOtherFetcher(to_repository=self.target,
 
1855
                                 from_repository=self.source,
 
1856
                                 last_revision=revision_id,
 
1857
                                 pb=pb)
 
1858
        return f.count_copied, f.failed_revisions
1832
1859
 
1833
1860
    @classmethod
1834
1861
    def _get_repo_format_to_test(self):