905
905
self.assertTrue(branch2.repository.has_revision('rev2a'))
906
906
self.assertEqual('rev2a', target_revision)
908
def test_bundle_empty_property(self):
909
"""Test serializing revision properties with an empty value."""
910
tree = self.make_branch_and_memory_tree('tree')
912
self.addCleanup(tree.unlock)
913
tree.add([''], ['TREE_ROOT'])
914
tree.commit('One', revprops={'one':'two', 'empty':''}, rev_id='rev1')
915
self.b1 = tree.branch
916
bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
917
self.assertContainsRe(bundle_sio.getvalue(),
919
'# branch-nick: tree\n'
923
bundle = read_bundle(bundle_sio)
924
revision_info = bundle.revisions[0]
925
self.assertEqual('rev1', revision_info.revision_id)
926
rev = revision_info.as_revision()
927
self.assertEqual({'branch-nick':'tree', 'empty':'', 'one':'two'},
930
def test_bundle_empty_property_alt(self):
931
"""Test serializing revision properties with an empty value.
933
Older readers had a bug when reading an empty property.
934
They assumed that all keys ended in ': \n'. However they would write an
935
empty value as ':\n'. This tests make sure that all newer bzr versions
936
can handle th second form.
938
tree = self.make_branch_and_memory_tree('tree')
940
self.addCleanup(tree.unlock)
941
tree.add([''], ['TREE_ROOT'])
942
tree.commit('One', revprops={'one':'two', 'empty':''}, rev_id='rev1')
943
self.b1 = tree.branch
944
bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
945
txt = bundle_sio.getvalue()
946
loc = txt.find('# empty: ') + len('# empty:')
947
# Create a new bundle, which strips the trailing space after empty
948
bundle_sio = StringIO(txt[:loc] + txt[loc+1:])
950
self.assertContainsRe(bundle_sio.getvalue(),
952
'# branch-nick: tree\n'
956
bundle = read_bundle(bundle_sio)
957
revision_info = bundle.revisions[0]
958
self.assertEqual('rev1', revision_info.revision_id)
959
rev = revision_info.as_revision()
960
self.assertEqual({'branch-nick':'tree', 'empty':'', 'one':'two'},
963
def test_bundle_sorted_properties(self):
964
"""For stability the writer should write properties in sorted order."""
965
tree = self.make_branch_and_memory_tree('tree')
967
self.addCleanup(tree.unlock)
969
tree.add([''], ['TREE_ROOT'])
970
tree.commit('One', rev_id='rev1',
971
revprops={'a':'4', 'b':'3', 'c':'2', 'd':'1'})
972
self.b1 = tree.branch
973
bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
974
self.assertContainsRe(bundle_sio.getvalue(),
978
'# branch-nick: tree\n'
982
bundle = read_bundle(bundle_sio)
983
revision_info = bundle.revisions[0]
984
self.assertEqual('rev1', revision_info.revision_id)
985
rev = revision_info.as_revision()
986
self.assertEqual({'branch-nick':'tree', 'a':'4', 'b':'3', 'c':'2',
987
'd':'1'}, rev.properties)
989
def test_bundle_unicode_properties(self):
990
"""We should be able to round trip a non-ascii property."""
991
tree = self.make_branch_and_memory_tree('tree')
993
self.addCleanup(tree.unlock)
995
tree.add([''], ['TREE_ROOT'])
996
# Revisions themselves do not require anything about revision property
997
# keys, other than that they are a basestring, and do not contain
999
# However, Testaments assert than they are str(), and thus should not
1001
tree.commit('One', rev_id='rev1',
1002
revprops={'omega':u'\u03a9', 'alpha':u'\u03b1'})
1003
self.b1 = tree.branch
1004
bundle_sio, revision_ids = self.create_bundle_text(None, 'rev1')
1005
self.assertContainsRe(bundle_sio.getvalue(),
1007
'# alpha: \xce\xb1\n'
1008
'# branch-nick: tree\n'
1009
'# omega: \xce\xa9\n'
1011
bundle = read_bundle(bundle_sio)
1012
revision_info = bundle.revisions[0]
1013
self.assertEqual('rev1', revision_info.revision_id)
1014
rev = revision_info.as_revision()
1015
self.assertEqual({'branch-nick':'tree', 'omega':u'\u03a9',
1016
'alpha':u'\u03b1'}, rev.properties)
909
1019
class V09BundleKnit2Tester(V08BundleTester):