121
121
self.local_wt.commit(message='test commit', rev_id=revid)
122
122
self.assertTrue(repo.has_revision(revid))
124
def test_remote_branch_revision_history(self):
125
b = BzrDir.open_from_transport(self.transport).open_branch()
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))
124
133
def test_find_correct_format(self):
125
134
"""Should open a RemoteBzrDir over a RemoteTransport"""
126
135
fmt = BzrDirFormat.find_format(self.transport)
340
349
class TestRemote(tests.TestCaseWithMemoryTransport):
342
351
def get_branch_format(self):
343
reference_bzrdir_format = controldir.format_registry.get('default')()
352
reference_bzrdir_format = bzrdir.format_registry.get('default')()
344
353
return reference_bzrdir_format.get_branch_format()
346
355
def get_repo_format(self):
347
reference_bzrdir_format = controldir.format_registry.get('default')()
356
reference_bzrdir_format = bzrdir.format_registry.get('default')()
348
357
return reference_bzrdir_format.repository_format
350
359
def assertFinished(self, fake_client):
466
475
transport = transport.clone('quack')
467
476
self.make_bzrdir('quack')
468
477
client = FakeClient(transport.base)
469
reference_bzrdir_format = controldir.format_registry.get('default')()
478
reference_bzrdir_format = bzrdir.format_registry.get('default')()
470
479
control_name = reference_bzrdir_format.network_name()
471
480
client.add_expected_call(
472
481
'BzrDir.cloning_metadir', ('quack/', 'False'),
500
509
def test__get_checkout_format(self):
501
510
transport = MemoryTransport()
502
511
client = FakeClient(transport.base)
503
reference_bzrdir_format = controldir.format_registry.get('default')()
512
reference_bzrdir_format = bzrdir.format_registry.get('default')()
504
513
control_name = reference_bzrdir_format.network_name()
505
514
client.add_expected_call(
506
515
'BzrDir.checkout_metadir', ('quack/', ),
537
546
def test_get_branches(self):
538
547
transport = MemoryTransport()
539
548
client = FakeClient(transport.base)
540
reference_bzrdir_format = controldir.format_registry.get('default')()
549
reference_bzrdir_format = bzrdir.format_registry.get('default')()
541
550
branch_name = reference_bzrdir_format.get_branch_format().network_name()
542
551
client.add_success_response_with_body(
543
552
bencode.bencode({
556
565
a_bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(),
558
567
result = a_bzrdir.get_branches()
559
self.assertEqual(set(["", "foo"]), set(result.keys()))
568
self.assertEquals(["", "foo"], result.keys())
560
569
self.assertEqual(
561
570
[('call_expecting_body', 'BzrDir.get_branches', ('quack/',)),
562
571
('call', 'BzrDir.find_repositoryV3', ('quack/', )),
845
854
transport = transport.clone('quack')
846
855
self.make_repository('quack')
847
856
client = FakeClient(transport.base)
848
reference_bzrdir_format = controldir.format_registry.get('default')()
857
reference_bzrdir_format = bzrdir.format_registry.get('default')()
849
858
reference_format = reference_bzrdir_format.get_branch_format()
850
859
network_name = reference_format.network_name()
851
860
reference_repo_fmt = reference_bzrdir_format.repository_format
873
882
# Client's medium rooted a transport root (not at the bzrdir)
874
883
client = FakeClient(transport.base)
875
884
transport = transport.clone('quack')
876
reference_bzrdir_format = controldir.format_registry.get('default')()
885
reference_bzrdir_format = bzrdir.format_registry.get('default')()
877
886
reference_format = reference_bzrdir_format.get_branch_format()
878
887
network_name = reference_format.network_name()
879
888
reference_repo_fmt = reference_bzrdir_format.repository_format
909
918
transport = transport.clone('quack')
910
919
self.make_bzrdir('quack')
911
920
client = FakeClient(transport.base)
912
reference_bzrdir_format = controldir.format_registry.get('default')()
921
reference_bzrdir_format = bzrdir.format_registry.get('default')()
913
922
reference_format = reference_bzrdir_format.repository_format
914
923
network_name = reference_format.network_name()
915
924
client.add_expected_call(
1287
1296
verb = 'Branch.set_parent_location'
1288
1297
self.disable_verb(verb)
1289
1298
branch.set_parent('http://foo/')
1290
self.assertLength(14, self.hpss_calls)
1299
self.assertLength(13, self.hpss_calls)
1293
1302
class TestBranchGetTagsBytes(RemoteBranchTestCase):
1448
1457
def test_backwards_compatible(self):
1449
br = self.make_branch_with_tags()
1450
br.get_config_stack().set('branch.fetch_tags', True)
1451
self.addCleanup(br.lock_read().unlock)
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)
1452
1462
# Disable the heads_to_fetch verb
1453
1463
verb = 'Branch.heads_to_fetch'
1454
1464
self.disable_verb(verb)
1455
1465
self.reset_smart_call_log()
1456
result = br.heads_to_fetch()
1466
result = branch.heads_to_fetch()
1457
1467
self.assertEqual((set(['tip']), set(['rev-1', 'rev-2'])), result)
1458
1468
self.assertEqual(
1459
['Branch.last_revision_info', 'Branch.get_tags_bytes'],
1469
['Branch.last_revision_info', 'Branch.get_config_file',
1470
'Branch.get_tags_bytes'],
1460
1471
[call.call.method for call in self.hpss_calls])
1462
1473
def test_backwards_compatible_no_tags(self):
1463
br = self.make_branch_with_tags()
1464
br.get_config_stack().set('branch.fetch_tags', False)
1465
self.addCleanup(br.lock_read().unlock)
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)
1466
1478
# Disable the heads_to_fetch verb
1467
1479
verb = 'Branch.heads_to_fetch'
1468
1480
self.disable_verb(verb)
1469
1481
self.reset_smart_call_log()
1470
result = br.heads_to_fetch()
1482
result = branch.heads_to_fetch()
1471
1483
self.assertEqual((set(['tip']), set()), result)
1472
1484
self.assertEqual(
1473
['Branch.last_revision_info'],
1485
['Branch.last_revision_info', 'Branch.get_config_file'],
1474
1486
[call.call.method for call in self.hpss_calls])
2061
2073
'Branch.get_config_file', ('memory:///', ),
2062
2074
'success', ('ok', ), "# line 1\n")
2063
2075
client.add_expected_call(
2064
'Branch.get_config_file', ('memory:///', ),
2065
'success', ('ok', ), "# line 1\n")
2066
client.add_expected_call(
2067
2076
'Branch.put_config_file', ('memory:///', 'branch token',
2069
2078
'success', ('ok',))
2081
2090
[('call', 'Branch.get_stacked_on_url', ('memory:///',)),
2082
2091
('call', 'Branch.lock_write', ('memory:///', '', '')),
2083
2092
('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
2084
('call_expecting_body', 'Branch.get_config_file', ('memory:///',)),
2085
2093
('call_with_body_bytes_expecting_body', 'Branch.put_config_file',
2086
2094
('memory:///', 'branch token', 'repo token'),
2087
2095
'# line 1\nemail = The Dude <lebowski@example.com>\n'),
2124
2132
transport.mkdir('quack')
2125
2133
transport = transport.clone('quack')
2126
2134
branch = self.make_remote_branch(transport, client)
2127
self.assertEqual(0, branch.revision_id_to_revno('null:'))
2135
self.assertEquals(0, branch.revision_id_to_revno('null:'))
2128
2136
self.assertRaises(errors.NoSuchRevision,
2129
2137
branch.revision_id_to_revno, 'unknown')
2130
2138
self.assertFinished(client)
2144
2152
transport.mkdir('quack')
2145
2153
transport = transport.clone('quack')
2146
2154
branch = self.make_remote_branch(transport, client)
2147
self.assertEqual((0, ), branch.revision_id_to_dotted_revno('null:'))
2155
self.assertEquals((0, ), branch.revision_id_to_dotted_revno('null:'))
2148
2156
self.assertRaises(errors.NoSuchRevision,
2149
2157
branch.revision_id_to_dotted_revno, 'unknown')
2150
2158
self.assertFinished(client)
2154
2162
branch = self.make_branch('.')
2155
2163
self.disable_verb('Branch.revision_id_to_revno')
2156
2164
self.reset_smart_call_log()
2157
self.assertEqual((0, ),
2165
self.assertEquals((0, ),
2158
2166
branch.revision_id_to_dotted_revno('null:'))
2159
2167
self.assertLength(8, self.hpss_calls)
2327
2335
transport_path = 'quack'
2328
2336
repo, client = self.setup_fake_client_and_repository(transport_path)
2329
2337
client.add_success_response_with_body('', 'ok')
2330
self.assertEqual([], repo.all_revision_ids())
2338
self.assertEquals([], repo.all_revision_ids())
2331
2339
self.assertEqual(
2332
2340
[('call_expecting_body', 'Repository.all_revision_ids',
2338
2346
repo, client = self.setup_fake_client_and_repository(transport_path)
2339
2347
client.add_success_response_with_body(
2340
2348
'rev1\nrev2\nanotherrev\n', 'ok')
2341
self.assertEqual(["rev1", "rev2", "anotherrev"],
2349
self.assertEquals(["rev1", "rev2", "anotherrev"],
2342
2350
repo.all_revision_ids())
2343
2351
self.assertEqual(
2344
2352
[('call_expecting_body', 'Repository.all_revision_ids',
2422
2430
transport_path = 'hill'
2423
2431
repo, client = self.setup_fake_client_and_repository(transport_path)
2424
2432
client.add_success_response('ok', '7')
2425
self.assertEqual('7', repo.get_serializer_format())
2433
self.assertEquals('7', repo.get_serializer_format())
2426
2434
self.assertEqual(
2427
2435
[('call', 'VersionedFileRepository.get_serializer_format',
2446
2454
('call_expecting_body', 'Repository.reconcile',
2447
2455
('hill/', 'a token'))],
2449
self.assertEqual(2, reconciler.garbage_inventories)
2450
self.assertEqual(3, reconciler.inconsistent_parents)
2457
self.assertEquals(2, reconciler.garbage_inventories)
2458
self.assertEquals(3, reconciler.inconsistent_parents)
2453
2461
class TestRepositoryGetRevisionSignatureText(TestRemoteRepository):
2458
2466
repo, client = self.setup_fake_client_and_repository(transport_path)
2459
2467
client.add_success_response_with_body(
2460
2468
'THETEXT', 'ok')
2461
self.assertEqual("THETEXT", repo.get_signature_text("revid"))
2469
self.assertEquals("THETEXT", repo.get_signature_text("revid"))
2462
2470
self.assertEqual(
2463
2471
[('call_expecting_body', 'Repository.get_revision_signature_text',
2464
2472
('quack/', 'revid'))],
2771
2779
client.add_success_response_with_body(
2772
2780
[body[:10], body[10:]], 'ok', '10')
2773
2781
revs = repo.get_revisions(['somerev1'])
2774
self.assertEqual(revs, [somerev1])
2782
self.assertEquals(revs, [somerev1])
2775
2783
self.assertEqual(
2776
2784
[('call_with_body_bytes_expecting_body', 'Repository.iter_revisions',
2777
2785
('quack/', ), "somerev1")],
3137
3145
def test_suspend_write_group(self):
3138
3146
transport_path = 'quack'
3139
3147
repo, client = self.setup_fake_client_and_repository(transport_path)
3140
self.assertEqual([], repo.suspend_write_group())
3148
self.assertEquals([], repo.suspend_write_group())
3142
3150
def test_resume_write_group(self):
3143
3151
transport_path = 'quack'
3227
3235
'success', ('ok',), iter(["ok\x000", "\n", zlib.compress("mydata" * 10)]))
3228
3236
for (identifier, byte_stream) in repo.iter_files_bytes([("somefile",
3229
3237
"somerev", "myid")]):
3230
self.assertEqual("myid", identifier)
3231
self.assertEqual("".join(byte_stream), "mydata" * 10)
3238
self.assertEquals("myid", identifier)
3239
self.assertEquals("".join(byte_stream), "mydata" * 10)
3233
3241
def test_missing(self):
3234
3242
transport_path = 'quack'
3955
3963
:result: The revision ids in the stream, in the order seen,
3956
3964
the topological order of revisions in the source.
3958
unordered_format = controldir.format_registry.get(format)()
3966
unordered_format = bzrdir.format_registry.get(format)()
3959
3967
target_repository_format = unordered_format.repository_format
3961
3969
self.assertEqual(order, target_repository_format._fetch_order)
4154
4162
def assertUpdateSucceeds(self, new_location):
4155
4163
self.checkout.branch.set_bound_location(new_location)
4156
4164
self.checkout.update()
4157
self.assertEqual(self.last_revid, self.checkout.last_revision())
4165
self.assertEquals(self.last_revid, self.checkout.last_revision())
4159
4167
def test_without_final_slash(self):
4160
4168
self.make_master_and_checkout('master', 'checkout')
4264
4272
def test_single_empty(self):
4265
4273
transport_path = 'quack'
4266
4274
repo, client = self.setup_fake_client_and_repository(transport_path)
4267
fmt = controldir.format_registry.get('2a')().repository_format
4275
fmt = bzrdir.format_registry.get('2a')().repository_format
4268
4276
repo._format = fmt
4269
4277
stream = [('inventory-deltas', [
4270
4278
versionedfile.FulltextContentFactory('somerevid', None, None,
4276
4284
ret = list(repo.iter_inventories(["somerevid"]))
4277
4285
self.assertLength(1, ret)
4279
self.assertEqual("somerevid", inv.revision_id)
4287
self.assertEquals("somerevid", inv.revision_id)
4281
4289
def test_empty(self):
4282
4290
transport_path = 'quack'
4283
4291
repo, client = self.setup_fake_client_and_repository(transport_path)
4284
4292
ret = list(repo.iter_inventories([]))
4285
self.assertEqual(ret, [])
4293
self.assertEquals(ret, [])
4287
4295
def test_missing(self):
4288
4296
transport_path = 'quack'