rbbz: add 5 lines of context to single-line reviews (
bug 1255278) r?mdoglio
When a review has selected a single line for context, add an additional 5 lines
of context to the comment created in Bugzilla. This provides parity with
Splinter, and falls in line with most user's expectations.
MozReview-Commit-ID: LoudBFRSgWz
--- a/pylib/rbbz/rbbz/diffs.py
+++ b/pylib/rbbz/rbbz/diffs.py
@@ -245,25 +245,38 @@ def render_comment_plain(comment, contex
else:
last_reply = parent_comment
lines = ["> %s" % line for line in str(last_reply).split('\n')]
lines.append("\n%s" % comment)
return "\n".join(lines)
+ # If the reviewer selected a single line, comment with
+ # 5 lines of context.
+ if comment.num_lines == 1:
+ if comment.first_line < 6:
+ first_line = 1
+ num_lines = comment.first_line
+ else:
+ first_line = comment.first_line - 5
+ num_lines = 6
+ else:
+ first_line = comment.first_line
+ num_lines = comment.num_lines
+
# This is the base comment of a review, so we
# should quote the code the comment is adressing.
parser = HTMLParser.HTMLParser()
chunks = list(get_file_chunks_in_range_custom(
context,
comment.filediff,
comment.interfilediff,
- comment.first_line,
- comment.num_lines))
+ first_line,
+ num_lines))
dest_lineno = None
for chunk in chunks:
for line in chunk['lines']:
if line[0] == comment.first_line:
# this is an empty string if the line does not exist in
# the destination file
dest_lineno = line[4]