summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-02-02 11:15:44 +0100
committerJelmer Vernooij <jelmer@samba.org>2011-02-02 11:15:44 +0100
commit801b2da38d8df513b93cf94455a3ec4c817bfad4 (patch)
tree68b9d0d60bd092427e6136d4b6abe2a59874ca6d
parent76db1c7174544db3223397743d81e9a67802577f (diff)
downloadbzr-fastimport-801b2da38d8df513b93cf94455a3ec4c817bfad4.tar.gz
Cope with non-utf8 characters in commit messages.
-rw-r--r--NEWS2
-rw-r--r--bzr_commit_handler.py3
-rw-r--r--tests/test_generic_processor.py17
3 files changed, 21 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 8bdbd84..6f38e42 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@ Bug fixes
* Strip leading slashes when exporting Subversion repositories.
(Jelmer Vernooij, #477869)
+* Cope with non-utf8 characters in commit messages. (Jelmer Vernooij, #444896)
+
0.9 28-Feb-2010
===============
diff --git a/bzr_commit_handler.py b/bzr_commit_handler.py
index d81b271..72c7807 100644
--- a/bzr_commit_handler.py
+++ b/bzr_commit_handler.py
@@ -276,10 +276,11 @@ class GenericCommitHandler(processor.CommitHandler):
who = self._format_name_email("committer", committer[0], committer[1])
try:
message = self.command.message.decode("utf-8")
+
except UnicodeDecodeError:
self.warning(
"commit message not in utf8 - replacing unknown characters")
- message = message.decode('utf-8', 'replace')
+ message = self.command.message.decode('utf-8', 'replace')
if not _serializer_handles_escaping:
# We need to assume the bad ol' days
message = helpers.escape_commit_message(message)
diff --git a/tests/test_generic_processor.py b/tests/test_generic_processor.py
index 41f846e..111fd56 100644
--- a/tests/test_generic_processor.py
+++ b/tests/test_generic_processor.py
@@ -1910,3 +1910,20 @@ class TestModifyRevertInBranch(TestCaseForGenericProcessor):
self.assertEqual(rev_b, rtree_b.inventory[foo_id].revision)
self.assertEqual(rev_c, rtree_c.inventory[foo_id].revision)
self.assertEqual(rev_c, rtree_d.inventory[foo_id].revision)
+
+
+class TestCommitCommands(TestCaseForGenericProcessor):
+
+ def test_non_utf8_commit_message(self):
+ handler, branch = self.get_handler()
+ def files_one():
+ yield commands.FileModifyCommand('a',
+ kind_to_mode('file', False), None, "data")
+ def command_list():
+ committer = ['', 'elmer@a.com', time.time(), time.timezone]
+ yield commands.CommitCommand('head', '1', None,
+ committer, 'This is a funky character: \x83', None, [],
+ files_one)
+ handler.process(command_list)
+ rev = branch.repository.get_revision(branch.last_revision())
+ self.assertEquals(u"This is a funky character: \ufffd", rev.message)