224
225
self.assertEqual(expected, request.execute('', 'False'))
228
class TestSmartServerBzrDirRequestCloningMetaDir(
229
tests.TestCaseWithMemoryTransport):
230
"""Tests for BzrDir.checkout_metadir."""
232
def test_checkout_metadir(self):
233
backing = self.get_transport()
234
request = smart_dir.SmartServerBzrDirRequestCheckoutMetaDir(
236
branch = self.make_branch('.', format='2a')
237
response = request.execute('')
239
smart_req.SmartServerResponse(
240
('Bazaar-NG meta directory, format 1\n',
241
'Bazaar repository format 2a (needs bzr 1.16 or later)\n',
242
'Bazaar Branch Format 7 (needs bzr 1.6)\n')),
227
246
class TestSmartServerBzrDirRequestDestroyBranch(
228
247
tests.TestCaseWithMemoryTransport):
229
248
"""Tests for BzrDir.destroy_branch."""
2477
2496
smart_dir.SmartServerRequestInitializeBzrDir)
2478
2497
self.assertHandlerEqual('BzrDirFormat.initialize_ex_1.16',
2479
2498
smart_dir.SmartServerRequestBzrDirInitializeEx)
2499
self.assertHandlerEqual('BzrDir.checkout_metadir',
2500
smart_dir.SmartServerBzrDirRequestCheckoutMetaDir)
2480
2501
self.assertHandlerEqual('BzrDir.cloning_metadir',
2481
2502
smart_dir.SmartServerBzrDirRequestCloningMetaDir)
2482
2503
self.assertHandlerEqual('BzrDir.get_config_file',
2545
2566
smart_repo.SmartServerRepositoryAbortWriteGroup)
2546
2567
self.assertHandlerEqual('VersionedFileRepository.get_serializer_format',
2547
2568
smart_repo.SmartServerRepositoryGetSerializerFormat)
2569
self.assertHandlerEqual('VersionedFileRepository.get_inventories',
2570
smart_repo.SmartServerRepositoryGetInventories)
2548
2571
self.assertHandlerEqual('Transport.is_readonly',
2549
2572
smart_req.SmartServerIsReadonly)
2610
2633
smart_req.SuccessfulSmartServerResponse(('ok', ), ),
2611
2634
request.do_body(''))
2637
class TestSmartServerRepositoryGetInventories(tests.TestCaseWithTransport):
2639
def _get_serialized_inventory_delta(self, repository, base_revid, revid):
2640
base_inv = repository.revision_tree(base_revid).inventory
2641
inv = repository.revision_tree(revid).inventory
2642
inv_delta = inv._make_delta(base_inv)
2643
serializer = inventory_delta.InventoryDeltaSerializer(True, False)
2644
return "".join(serializer.delta_to_lines(base_revid, revid, inv_delta))
2646
def test_single(self):
2647
backing = self.get_transport()
2648
request = smart_repo.SmartServerRepositoryGetInventories(backing)
2649
t = self.make_branch_and_tree('.', format='2a')
2650
self.addCleanup(t.lock_write().unlock)
2651
self.build_tree_contents([("file", "somecontents")])
2652
t.add(["file"], ["thefileid"])
2653
t.commit(rev_id='somerev', message="add file")
2654
self.assertIs(None, request.execute('', 'unordered'))
2655
response = request.do_body("somerev\n")
2656
self.assertTrue(response.is_successful())
2657
self.assertEquals(response.args, ("ok", ))
2658
stream = [('inventory-deltas', [
2659
versionedfile.FulltextContentFactory('somerev', None, None,
2660
self._get_serialized_inventory_delta(
2661
t.branch.repository, 'null:', 'somerev'))])]
2662
fmt = bzrdir.format_registry.get('2a')().repository_format
2664
"".join(response.body_stream),
2665
"".join(smart_repo._stream_to_byte_stream(stream, fmt)))
2667
def test_empty(self):
2668
backing = self.get_transport()
2669
request = smart_repo.SmartServerRepositoryGetInventories(backing)
2670
t = self.make_branch_and_tree('.', format='2a')
2671
self.addCleanup(t.lock_write().unlock)
2672
self.build_tree_contents([("file", "somecontents")])
2673
t.add(["file"], ["thefileid"])
2674
t.commit(rev_id='somerev', message="add file")
2675
self.assertIs(None, request.execute('', 'unordered'))
2676
response = request.do_body("")
2677
self.assertTrue(response.is_successful())
2678
self.assertEquals(response.args, ("ok", ))
2679
self.assertEquals("".join(response.body_stream),
2680
"Bazaar pack format 1 (introduced in 0.18)\nB54\n\nBazaar repository format 2a (needs bzr 1.16 or later)\nE")