Merge lp:~wgrant/launchpad/diff-no-newline into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17618
Proposed branch: lp:~wgrant/launchpad/diff-no-newline
Merge into: lp:launchpad
Diff against target: 53 lines (+14/-11)
2 files modified
lib/lp/code/mail/codereviewcomment.py (+12/-10)
lib/lp/code/mail/tests/test_codereviewcomment.py (+2/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/diff-no-newline
Reviewer Review Type Date Requested Status
Kit Randel (community) Approve
Review via email: mp+264254@code.launchpad.net

Commit message

Cope with "No newline at end of file" lines in diff emails, which bzrlib merges into the previous line.

Description of the change

Cope with "No newline at end of file" lines in diff emails, which bzrlib merges into the previous line. Look for NO_NL in patches.py to see the weird parsing implementation.

To post a comment you must log in.
Revision history for this message
Kit Randel (blr) wrote :

Glad you added a comment; not what I would have expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/mail/codereviewcomment.py'
--- lib/lp/code/mail/codereviewcomment.py 2015-07-09 05:40:01 +0000
+++ lib/lp/code/mail/codereviewcomment.py 2015-07-09 10:44:14 +0000
@@ -244,16 +244,18 @@
244 hunk_lines.extend(format_comment(comment))244 hunk_lines.extend(format_comment(comment))
245 hunk_comment = True245 hunk_comment = True
246246
247 for line in hunk.lines:247 for hunk_line in hunk.lines:
248 line_count += 1 # inc hunk lines248 # A single HunkLine can actually represent multiple
249249 # lines in the "No newline at end of file" case.
250 # line is a ContextLine/ReplaceLine250 hunk_line = str(hunk_line)
251 hunk_lines.append(u'> %s' % str(line).rstrip('\n').decode(251 for line in hunk_line.splitlines():
252 'utf-8', 'replace'))252 line_count += 1 # inc hunk lines
253 comment = comments.get(str(line_count))253 hunk_lines.append(u'> %s' % line.rstrip('\n').decode(
254 if comment:254 'utf-8', 'replace'))
255 hunk_lines.extend(format_comment(comment))255 comment = comments.get(str(line_count))
256 hunk_comment = True256 if comment:
257 hunk_lines.extend(format_comment(comment))
258 hunk_comment = True
257259
258 # preserve hunks for context if comment in patch header260 # preserve hunks for context if comment in patch header
259 if patch_comment or hunk_comment:261 if patch_comment or hunk_comment:
260262
=== modified file 'lib/lp/code/mail/tests/test_codereviewcomment.py'
--- lib/lp/code/mail/tests/test_codereviewcomment.py 2015-07-09 03:12:29 +0000
+++ lib/lp/code/mail/tests/test_codereviewcomment.py 2015-07-09 10:44:14 +0000
@@ -404,6 +404,7 @@
404 " c\n"404 " c\n"
405 "+d\n"405 "+d\n"
406 "+e\n"406 "+e\n"
407 "\\ No newline at end of file\n"
407 "\n"408 "\n"
408 "=== modified file 'fulango.py'\n"409 "=== modified file 'fulango.py'\n"
409 "--- fulano.py\t2014-08-26 15:53:34.000000000 -0400\n"410 "--- fulano.py\t2014-08-26 15:53:34.000000000 -0400\n"
@@ -618,7 +619,7 @@
618 self.getSection(comments).splitlines()[4:12])619 self.getSection(comments).splitlines()[4:12])
619620
620 def test_comment_in_patch_after_linebreak(self):621 def test_comment_in_patch_after_linebreak(self):
621 comments = {'31': 'que?'}622 comments = {'32': 'que?'}
622 self.assertEqual(623 self.assertEqual(
623 map(unicode, [624 map(unicode, [
624 "> ",625 "> ",