Merge ~cjwatson/launchpad:py3-revisionsaddedjob-stringio into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 73a2c4a87e1fc9f2dfa7d06dc3f55158b441eb86
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-revisionsaddedjob-stringio
Merge into: launchpad:master
Diff against target: 51 lines (+9/-5)
1 file modified
lib/lp/code/model/branchjob.py (+9/-5)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+391086@code.launchpad.net

Commit message

Port RevisionsAddedJob.getRevisionMessage away from StringIO.StringIO

Description of the change

show_diff_trees expects to write to a binary file, while show_log expects to write native strings.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM, with a minor comment.

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Thiago F. Pappacena (pappacena) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py
2index 7067f8a..3463db7 100644
3--- a/lib/lp/code/model/branchjob.py
4+++ b/lib/lp/code/model/branchjob.py
5@@ -13,10 +13,10 @@ __all__ = [
6 'RosettaUploadJob',
7 ]
8
9+import io
10 import operator
11 import os
12 import shutil
13-from StringIO import StringIO
14 import tempfile
15
16 from breezy.branch import Branch as BzrBranch
17@@ -567,7 +567,11 @@ class RevisionsAddedJob(BranchJobDerived):
18 mailer.sendAll()
19
20 def getDiffForRevisions(self, from_revision_id, to_revision_id):
21- """Generate the diff between from_revision_id and to_revision_id."""
22+ """Generate the diff between from_revision_id and to_revision_id.
23+
24+ This always returns Unicode text, decoding as UTF-8 with replacement
25+ characters where necessary.
26+ """
27 # Try to reuse a tree from the last time through.
28 repository = self.bzr_branch.repository
29 from_tree = self._tree_cache.get(from_revision_id)
30@@ -580,10 +584,10 @@ class RevisionsAddedJob(BranchJobDerived):
31 self._tree_cache = {
32 from_revision_id: from_tree, to_revision_id: to_tree}
33 # Now generate the diff.
34- diff_content = StringIO()
35+ diff_content = io.BytesIO()
36 show_diff_trees(
37 from_tree, to_tree, diff_content, old_label='', new_label='')
38- return diff_content.getvalue()
39+ return six.ensure_text(diff_content.getvalue(), errors='replace')
40
41 def getMailerForRevision(self, revision, revno, generate_diff):
42 """Return a BranchMailer for a revision.
43@@ -701,7 +705,7 @@ class RevisionsAddedJob(BranchJobDerived):
44 authors = self.getAuthors(merged_revisions, graph)
45 revision_set = RevisionSet()
46 rev_authors = revision_set.acquireRevisionAuthors(authors)
47- outf = StringIO()
48+ outf = six.StringIO()
49 pretty_authors = []
50 for rev_author in rev_authors.values():
51 if rev_author.person is None:

Subscribers

People subscribed via source and target branches

to status/vote changes: