871
871
self.assertEqual([{'path':'a', 'file_id':'a-id',
872
872
'message':'Message for A\n'},
873
873
], bencode.bdecode(file_info))
875
def test_commit_unicode_messages(self):
876
from bzrlib.tests.test_diff import UnicodeFilename
877
self.requireFeature(UnicodeFilename)
879
tree = self.make_branch_and_tree('tree')
880
self.build_tree(['tree/a', u'tree/\u03a9'])
881
tree.add(['a', u'\u03a9'], ['a-id', 'omega-id'])
883
dlg = commit.CommitDialog(tree)
884
dlg._treeview_files.set_cursor((1,)) # 'a'
885
dlg._set_file_commit_message(u'Test \xfan\xecc\xf6de\n')
886
dlg._treeview_files.set_cursor((2,)) # omega
887
dlg._set_file_commit_message(u'\u03a9 is the end of all things.\n')
888
dlg._set_global_commit_message(u'\u03a9 and \xfan\xecc\xf6de\n')
890
self.assertEqual(([u'a', u'\u03a9'],
891
[{'path':'a', 'file_id':'a-id',
892
'message':'Test \xc3\xban\xc3\xacc\xc3\xb6de\n'},
893
{'path':'\xce\xa9', 'file_id':'omega-id',
894
'message':'\xce\xa9 is the end of all things.\n'},
895
]), dlg._get_specific_files())
899
rev = tree.branch.repository.get_revision(dlg.committed_revision_id)
900
file_info = rev.properties['file-info']
901
value = ('ld7:file_id4:a-id'
902
'7:message16:Test \xc3\xban\xc3\xacc\xc3\xb6de\n'
905
'd7:file_id8:omega-id'
906
'7:message29:\xce\xa9 is the end of all things.\n'
910
self.expectFailure('bencode and unicode does not mix properly with'
911
' Revision XML serialization.',
912
self.assertEqual, value, file_info)
913
self.assertEqual(value, file_info)
914
file_info_decoded = bencode.bdecode(file_info)
915
for d in file_info_decoded:
916
d['path'] = d['path'].decode('utf8')
917
d['message'] = d['message'].decode('utf8')
919
self.assertEqual([{'path':u'a', 'file_id':'a-id',
920
'message':u'Test \xfan\xecc\xf6de\n'},
921
{'path':u'\u03a9', 'file_id':'omega-id',
922
'message':u'\u03a9 is the end of all things.\n'},
923
], file_info_decoded)