~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/repository_implementations/test_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-18 01:16:25 UTC
  • mfrom: (3184.1.13 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080118011625-465mgy0mhdz1jiky
(robertc) Reduce traffic when requesting revision streams from a
        smart server (3 MB to 172 bytes for a full bzr.dev pull)
        (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    bzrdir,
25
25
    errors,
 
26
    graph,
26
27
    remote,
27
28
    repository,
28
29
    )
35
36
    )
36
37
from bzrlib.revision import NULL_REVISION, Revision
37
38
from bzrlib.smart import server
 
39
from bzrlib.symbol_versioning import one_two
38
40
from bzrlib.tests import (
39
41
    KnownFailure,
40
42
    TestCaseWithTransport,
389
391
        repo._format.rich_root_data
390
392
        repo._format.supports_tree_reference
391
393
 
392
 
    def test_get_data_stream(self):
 
394
    def test_get_data_stream_deprecated(self):
 
395
        # If get_data_stream is present it must be deprecated
 
396
        tree = self.make_branch_and_tree('t')
 
397
        self.build_tree(['t/foo'])
 
398
        tree.add('foo', 'file1')
 
399
        tree.commit('message', rev_id='rev_id')
 
400
        repo = tree.branch.repository
 
401
        try:
 
402
            stream = self.applyDeprecated(one_two, repo.get_data_stream,
 
403
                ['rev_id'])
 
404
        except NotImplementedError:
 
405
            raise TestNotApplicable("%s doesn't support get_data_stream"
 
406
                % repo._format)
 
407
        except AttributeError:
 
408
            pass
 
409
 
 
410
    def test_get_data_stream_for_search(self):
393
411
        # Make a repo with a revision
394
412
        tree = self.make_branch_and_tree('t')
395
413
        self.build_tree(['t/foo'])
398
416
        repo = tree.branch.repository
399
417
 
400
418
        # Get a data stream (a file-like object) for that revision
 
419
        search = graph.SearchResult(set(['rev_id']), set([NULL_REVISION]), 1,
 
420
            set(['rev_id']))
401
421
        try:
402
 
            stream = repo.get_data_stream(['rev_id'])
 
422
            stream = repo.get_data_stream_for_search(search)
403
423
        except NotImplementedError:
404
424
            raise TestNotApplicable("%s doesn't support get_data_stream"
405
425
                % repo._format)
441
461
        source_repo = tree.branch.repository
442
462
        dest_repo = self.make_repository('dest')
443
463
        try:
444
 
            stream = source_repo.get_data_stream(['rev_id'])
 
464
            stream = source_repo.get_data_stream_for_search(
 
465
                dest_repo.search_missing_revision_ids(source_repo,
 
466
                    revision_id='rev_id'))
445
467
        except NotImplementedError, e:
446
468
            # Not all repositories support streaming.
447
 
            self.assertContainsRe(str(e), 'get_data_stream')
 
469
            self.assertContainsRe(str(e), 'get_data_stream_for_search')
448
470
            raise TestSkipped('This format does not support streaming.')
449
471
 
450
472
        dest_repo.lock_write()