Merge lp:~jelmer/brz/ignore-unicode-thingy into lp:brz

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/brz/ignore-unicode-thingy
Merge into: lp:brz
Diff against target: 47 lines (+23/-4)
2 files modified
breezy/git/mapping.py (+8/-4)
breezy/git/tests/test_mapping.py (+15/-0)
To merge this branch: bzr merge lp:~jelmer/brz/ignore-unicode-thingy
Reviewer Review Type Date Requested Status
Breezy developers Pending
Review via email: mp+365626@code.launchpad.net

This proposal has been superseded by a proposal from 2019-06-02.

Description of the change

Cope with utf-8 invalid characters in commit messages when scanning for revision ids.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/mapping.py'
2--- breezy/git/mapping.py 2019-02-11 19:40:51 +0000
3+++ breezy/git/mapping.py 2019-04-07 00:36:55 +0000
4@@ -383,10 +383,14 @@
5 encoding = commit.encoding.decode('ascii')
6 else:
7 encoding = 'utf-8'
8- message, metadata = self._decode_commit_message(
9- None, commit.message, encoding)
10- if metadata.revision_id:
11- return metadata.revision_id
12+ try:
13+ message, metadata = self._decode_commit_message(
14+ None, commit.message, encoding)
15+ except UnicodeDecodeError:
16+ pass
17+ else:
18+ if metadata.revision_id:
19+ return metadata.revision_id
20 return self.revision_id_foreign_to_bzr(commit.id)
21
22 def import_commit(self, commit, lookup_parent_revid):
23
24=== modified file 'breezy/git/tests/test_mapping.py'
25--- breezy/git/tests/test_mapping.py 2019-02-11 19:40:51 +0000
26+++ breezy/git/tests/test_mapping.py 2019-04-07 00:36:55 +0000
27@@ -239,6 +239,21 @@
28 mapping.revision_id_foreign_to_bzr(c.id),
29 mapping.get_revision_id(c))
30
31+ def test_invalid_utf8(self):
32+ c = Commit()
33+ c.tree = b"cc9462f7f8263ef5adfbeff2fb936bb36b504cba"
34+ c.message = b"Some message \xc1"
35+ c.committer = b"Committer"
36+ c.commit_time = 4
37+ c.author_time = 5
38+ c.commit_timezone = 60 * 5
39+ c.author_timezone = 60 * 3
40+ c.author = b"Author"
41+ mapping = BzrGitMappingv1()
42+ self.assertEqual(
43+ mapping.revision_id_foreign_to_bzr(c.id),
44+ mapping.get_revision_id(c))
45+
46
47 class RoundtripRevisionsFromBazaar(tests.TestCase):
48

Subscribers

People subscribed via source and target branches