Show More
@@ -371,6 +371,7 b' class DiffSet(object):' | |||||
371 | self.repo_name = repo_name |
|
371 | self.repo_name = repo_name | |
372 | self.source_repo_name = source_repo_name or repo_name |
|
372 | self.source_repo_name = source_repo_name or repo_name | |
373 | self.comments = comments or {} |
|
373 | self.comments = comments or {} | |
|
374 | self.comments_store = self.comments.copy() | |||
374 | self.max_file_size_limit = max_file_size_limit |
|
375 | self.max_file_size_limit = max_file_size_limit | |
375 |
|
376 | |||
376 | def render_patchset(self, patchset, source_ref=None, target_ref=None): |
|
377 | def render_patchset(self, patchset, source_ref=None, target_ref=None): | |
@@ -475,6 +476,18 b' class DiffSet(object):' | |||||
475 | hunkbit = self.parse_hunk(hunk, source_file, target_file) |
|
476 | hunkbit = self.parse_hunk(hunk, source_file, target_file) | |
476 | hunkbit.filediff = filediff |
|
477 | hunkbit.filediff = filediff | |
477 | filediff.hunks.append(hunkbit) |
|
478 | filediff.hunks.append(hunkbit) | |
|
479 | ||||
|
480 | left_comments = {} | |||
|
481 | ||||
|
482 | if source_file_path in self.comments_store: | |||
|
483 | for lineno, comments in self.comments_store[source_file_path].items(): | |||
|
484 | left_comments[lineno] = comments | |||
|
485 | ||||
|
486 | if target_file_path in self.comments_store: | |||
|
487 | for lineno, comments in self.comments_store[target_file_path].items(): | |||
|
488 | left_comments[lineno] = comments | |||
|
489 | ||||
|
490 | filediff.left_comments = left_comments | |||
478 | return filediff |
|
491 | return filediff | |
479 |
|
492 | |||
480 | def parse_hunk(self, hunk, source_file, target_file): |
|
493 | def parse_hunk(self, hunk, source_file, target_file): | |
@@ -507,6 +520,7 b' class DiffSet(object):' | |||||
507 | self.parse_lines(before, after, source_file, target_file)) |
|
520 | self.parse_lines(before, after, source_file, target_file)) | |
508 | result.unified = self.as_unified(result.lines) |
|
521 | result.unified = self.as_unified(result.lines) | |
509 | result.sideside = result.lines |
|
522 | result.sideside = result.lines | |
|
523 | ||||
510 | return result |
|
524 | return result | |
511 |
|
525 | |||
512 | def parse_lines(self, before_lines, after_lines, source_file, target_file): |
|
526 | def parse_lines(self, before_lines, after_lines, source_file, target_file): | |
@@ -589,7 +603,10 b' class DiffSet(object):' | |||||
589 | 'new': 'n', |
|
603 | 'new': 'n', | |
590 | }[version] + str(line_number) |
|
604 | }[version] + str(line_number) | |
591 |
|
605 | |||
592 | return self.comments.get(file, {}).get(line_key) |
|
606 | if file in self.comments_store: | |
|
607 | file_comments = self.comments_store[file] | |||
|
608 | if line_key in file_comments: | |||
|
609 | return file_comments.pop(line_key) | |||
593 |
|
610 | |||
594 | def get_line_tokens(self, line_text, line_number, file=None): |
|
611 | def get_line_tokens(self, line_text, line_number, file=None): | |
595 | filenode = None |
|
612 | filenode = None | |
@@ -628,7 +645,9 b' class DiffSet(object):' | |||||
628 | }.get(action, action) |
|
645 | }.get(action, action) | |
629 |
|
646 | |||
630 | def as_unified(self, lines): |
|
647 | def as_unified(self, lines): | |
631 | """ Return a generator that yields the lines of a diff in unified order """ |
|
648 | """ | |
|
649 | Return a generator that yields the lines of a diff in unified order | |||
|
650 | """ | |||
632 | def generator(): |
|
651 | def generator(): | |
633 | buf = [] |
|
652 | buf = [] | |
634 | for line in lines: |
|
653 | for line in lines: |
General Comments 0
You need to be logged in to leave comments.
Login now