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
diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py
index 7067f8a..3463db7 100644
--- a/lib/lp/code/model/branchjob.py
+++ b/lib/lp/code/model/branchjob.py
@@ -13,10 +13,10 @@ __all__ = [
13 'RosettaUploadJob',13 'RosettaUploadJob',
14]14]
1515
16import io
16import operator17import operator
17import os18import os
18import shutil19import shutil
19from StringIO import StringIO
20import tempfile20import tempfile
2121
22from breezy.branch import Branch as BzrBranch22from breezy.branch import Branch as BzrBranch
@@ -567,7 +567,11 @@ class RevisionsAddedJob(BranchJobDerived):
567 mailer.sendAll()567 mailer.sendAll()
568568
569 def getDiffForRevisions(self, from_revision_id, to_revision_id):569 def getDiffForRevisions(self, from_revision_id, to_revision_id):
570 """Generate the diff between from_revision_id and to_revision_id."""570 """Generate the diff between from_revision_id and to_revision_id.
571
572 This always returns Unicode text, decoding as UTF-8 with replacement
573 characters where necessary.
574 """
571 # Try to reuse a tree from the last time through.575 # Try to reuse a tree from the last time through.
572 repository = self.bzr_branch.repository576 repository = self.bzr_branch.repository
573 from_tree = self._tree_cache.get(from_revision_id)577 from_tree = self._tree_cache.get(from_revision_id)
@@ -580,10 +584,10 @@ class RevisionsAddedJob(BranchJobDerived):
580 self._tree_cache = {584 self._tree_cache = {
581 from_revision_id: from_tree, to_revision_id: to_tree}585 from_revision_id: from_tree, to_revision_id: to_tree}
582 # Now generate the diff.586 # Now generate the diff.
583 diff_content = StringIO()587 diff_content = io.BytesIO()
584 show_diff_trees(588 show_diff_trees(
585 from_tree, to_tree, diff_content, old_label='', new_label='')589 from_tree, to_tree, diff_content, old_label='', new_label='')
586 return diff_content.getvalue()590 return six.ensure_text(diff_content.getvalue(), errors='replace')
587591
588 def getMailerForRevision(self, revision, revno, generate_diff):592 def getMailerForRevision(self, revision, revno, generate_diff):
589 """Return a BranchMailer for a revision.593 """Return a BranchMailer for a revision.
@@ -701,7 +705,7 @@ class RevisionsAddedJob(BranchJobDerived):
701 authors = self.getAuthors(merged_revisions, graph)705 authors = self.getAuthors(merged_revisions, graph)
702 revision_set = RevisionSet()706 revision_set = RevisionSet()
703 rev_authors = revision_set.acquireRevisionAuthors(authors)707 rev_authors = revision_set.acquireRevisionAuthors(authors)
704 outf = StringIO()708 outf = six.StringIO()
705 pretty_authors = []709 pretty_authors = []
706 for rev_author in rev_authors.values():710 for rev_author in rev_authors.values():
707 if rev_author.person is None:711 if rev_author.person is None:

Subscribers

People subscribed via source and target branches

to status/vote changes: