2565
2566
smart_repo.SmartServerRepositoryAbortWriteGroup)
2566
2567
self.assertHandlerEqual('VersionedFileRepository.get_serializer_format',
2567
2568
smart_repo.SmartServerRepositoryGetSerializerFormat)
2569
self.assertHandlerEqual('VersionedFileRepository.get_inventories',
2570
smart_repo.SmartServerRepositoryGetInventories)
2568
2571
self.assertHandlerEqual('Transport.is_readonly',
2569
2572
smart_req.SmartServerIsReadonly)
2630
2633
smart_req.SuccessfulSmartServerResponse(('ok', ), ),
2631
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")