~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-16 11:08:11 UTC
  • mfrom: (6521 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6522.
  • Revision ID: jelmer@samba.org-20120416110811-0y996ihqy9o2bb1t
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
121
121
        self.local_wt.commit(message='test commit', rev_id=revid)
122
122
        self.assertTrue(repo.has_revision(revid))
123
123
 
124
 
    def test_remote_branch_revision_history(self):
125
 
        b = BzrDir.open_from_transport(self.transport).open_branch()
126
 
        self.assertEqual([],
127
 
            self.applyDeprecated(deprecated_in((2, 5, 0)), b.revision_history))
128
 
        r1 = self.local_wt.commit('1st commit')
129
 
        r2 = self.local_wt.commit('1st commit', rev_id=u'\xc8'.encode('utf8'))
130
 
        self.assertEqual([r1, r2],
131
 
            self.applyDeprecated(deprecated_in((2, 5, 0)), b.revision_history))
132
 
 
133
124
    def test_find_correct_format(self):
134
125
        """Should open a RemoteBzrDir over a RemoteTransport"""
135
126
        fmt = BzrDirFormat.find_format(self.transport)
349
340
class TestRemote(tests.TestCaseWithMemoryTransport):
350
341
 
351
342
    def get_branch_format(self):
352
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
343
        reference_bzrdir_format = controldir.format_registry.get('default')()
353
344
        return reference_bzrdir_format.get_branch_format()
354
345
 
355
346
    def get_repo_format(self):
356
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
347
        reference_bzrdir_format = controldir.format_registry.get('default')()
357
348
        return reference_bzrdir_format.repository_format
358
349
 
359
350
    def assertFinished(self, fake_client):
475
466
        transport = transport.clone('quack')
476
467
        self.make_bzrdir('quack')
477
468
        client = FakeClient(transport.base)
478
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
469
        reference_bzrdir_format = controldir.format_registry.get('default')()
479
470
        control_name = reference_bzrdir_format.network_name()
480
471
        client.add_expected_call(
481
472
            'BzrDir.cloning_metadir', ('quack/', 'False'),
509
500
    def test__get_checkout_format(self):
510
501
        transport = MemoryTransport()
511
502
        client = FakeClient(transport.base)
512
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
503
        reference_bzrdir_format = controldir.format_registry.get('default')()
513
504
        control_name = reference_bzrdir_format.network_name()
514
505
        client.add_expected_call(
515
506
            'BzrDir.checkout_metadir', ('quack/', ),
546
537
    def test_get_branches(self):
547
538
        transport = MemoryTransport()
548
539
        client = FakeClient(transport.base)
549
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
540
        reference_bzrdir_format = controldir.format_registry.get('default')()
550
541
        branch_name = reference_bzrdir_format.get_branch_format().network_name()
551
542
        client.add_success_response_with_body(
552
543
            bencode.bencode({
565
556
        a_bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(),
566
557
            _client=client)
567
558
        result = a_bzrdir.get_branches()
568
 
        self.assertEquals(["", "foo"], result.keys())
 
559
        self.assertEquals(set(["", "foo"]), set(result.keys()))
569
560
        self.assertEqual(
570
561
            [('call_expecting_body', 'BzrDir.get_branches', ('quack/',)),
571
562
             ('call', 'BzrDir.find_repositoryV3', ('quack/', )),
854
845
        transport = transport.clone('quack')
855
846
        self.make_repository('quack')
856
847
        client = FakeClient(transport.base)
857
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
848
        reference_bzrdir_format = controldir.format_registry.get('default')()
858
849
        reference_format = reference_bzrdir_format.get_branch_format()
859
850
        network_name = reference_format.network_name()
860
851
        reference_repo_fmt = reference_bzrdir_format.repository_format
882
873
        # Client's medium rooted a transport root (not at the bzrdir)
883
874
        client = FakeClient(transport.base)
884
875
        transport = transport.clone('quack')
885
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
876
        reference_bzrdir_format = controldir.format_registry.get('default')()
886
877
        reference_format = reference_bzrdir_format.get_branch_format()
887
878
        network_name = reference_format.network_name()
888
879
        reference_repo_fmt = reference_bzrdir_format.repository_format
918
909
        transport = transport.clone('quack')
919
910
        self.make_bzrdir('quack')
920
911
        client = FakeClient(transport.base)
921
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
912
        reference_bzrdir_format = controldir.format_registry.get('default')()
922
913
        reference_format = reference_bzrdir_format.repository_format
923
914
        network_name = reference_format.network_name()
924
915
        client.add_expected_call(
1296
1287
        verb = 'Branch.set_parent_location'
1297
1288
        self.disable_verb(verb)
1298
1289
        branch.set_parent('http://foo/')
1299
 
        self.assertLength(13, self.hpss_calls)
 
1290
        self.assertLength(14, self.hpss_calls)
1300
1291
 
1301
1292
 
1302
1293
class TestBranchGetTagsBytes(RemoteBranchTestCase):
1455
1446
        return branch
1456
1447
 
1457
1448
    def test_backwards_compatible(self):
1458
 
        branch = self.make_branch_with_tags()
1459
 
        c = branch.get_config_stack()
1460
 
        c.set('branch.fetch_tags', True)
1461
 
        self.addCleanup(branch.lock_read().unlock)
 
1449
        br = self.make_branch_with_tags()
 
1450
        br.get_config_stack().set('branch.fetch_tags', True)
 
1451
        self.addCleanup(br.lock_read().unlock)
1462
1452
        # Disable the heads_to_fetch verb
1463
1453
        verb = 'Branch.heads_to_fetch'
1464
1454
        self.disable_verb(verb)
1465
1455
        self.reset_smart_call_log()
1466
 
        result = branch.heads_to_fetch()
 
1456
        result = br.heads_to_fetch()
1467
1457
        self.assertEqual((set(['tip']), set(['rev-1', 'rev-2'])), result)
1468
1458
        self.assertEqual(
1469
 
            ['Branch.last_revision_info', 'Branch.get_config_file',
1470
 
             'Branch.get_tags_bytes'],
 
1459
            ['Branch.last_revision_info', 'Branch.get_tags_bytes'],
1471
1460
            [call.call.method for call in self.hpss_calls])
1472
1461
 
1473
1462
    def test_backwards_compatible_no_tags(self):
1474
 
        branch = self.make_branch_with_tags()
1475
 
        c = branch.get_config_stack()
1476
 
        c.set('branch.fetch_tags', False)
1477
 
        self.addCleanup(branch.lock_read().unlock)
 
1463
        br = self.make_branch_with_tags()
 
1464
        br.get_config_stack().set('branch.fetch_tags', False)
 
1465
        self.addCleanup(br.lock_read().unlock)
1478
1466
        # Disable the heads_to_fetch verb
1479
1467
        verb = 'Branch.heads_to_fetch'
1480
1468
        self.disable_verb(verb)
1481
1469
        self.reset_smart_call_log()
1482
 
        result = branch.heads_to_fetch()
 
1470
        result = br.heads_to_fetch()
1483
1471
        self.assertEqual((set(['tip']), set()), result)
1484
1472
        self.assertEqual(
1485
 
            ['Branch.last_revision_info', 'Branch.get_config_file'],
 
1473
            ['Branch.last_revision_info'],
1486
1474
            [call.call.method for call in self.hpss_calls])
1487
1475
 
1488
1476
 
2073
2061
            'Branch.get_config_file', ('memory:///', ),
2074
2062
            'success', ('ok', ), "# line 1\n")
2075
2063
        client.add_expected_call(
 
2064
            'Branch.get_config_file', ('memory:///', ),
 
2065
            'success', ('ok', ), "# line 1\n")
 
2066
        client.add_expected_call(
2076
2067
            'Branch.put_config_file', ('memory:///', 'branch token',
2077
2068
            'repo token'),
2078
2069
            'success', ('ok',))
2090
2081
            [('call', 'Branch.get_stacked_on_url', ('memory:///',)),
2091
2082
             ('call', 'Branch.lock_write', ('memory:///', '', '')),
2092
2083
             ('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
 
2084
             ('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
2093
2085
             ('call_with_body_bytes_expecting_body', 'Branch.put_config_file',
2094
2086
                 ('memory:///', 'branch token', 'repo token'),
2095
2087
                 '# line 1\nemail = The Dude <lebowski@example.com>\n'),
3963
3955
        :result: The revision ids in the stream, in the order seen,
3964
3956
            the topological order of revisions in the source.
3965
3957
        """
3966
 
        unordered_format = bzrdir.format_registry.get(format)()
 
3958
        unordered_format = controldir.format_registry.get(format)()
3967
3959
        target_repository_format = unordered_format.repository_format
3968
3960
        # Cross check
3969
3961
        self.assertEqual(order, target_repository_format._fetch_order)
4272
4264
    def test_single_empty(self):
4273
4265
        transport_path = 'quack'
4274
4266
        repo, client = self.setup_fake_client_and_repository(transport_path)
4275
 
        fmt = bzrdir.format_registry.get('2a')().repository_format
 
4267
        fmt = controldir.format_registry.get('2a')().repository_format
4276
4268
        repo._format = fmt
4277
4269
        stream = [('inventory-deltas', [
4278
4270
            versionedfile.FulltextContentFactory('somerevid', None, None,