##// END OF EJS Templates
comments: save comments that are not rendered to be displayed as outdated....
marcink -
r1258:70c673b5 default
parent child Browse files
Show More
@@ -371,6 +371,7 b' class DiffSet(object):'
371 371 self.repo_name = repo_name
372 372 self.source_repo_name = source_repo_name or repo_name
373 373 self.comments = comments or {}
374 self.comments_store = self.comments.copy()
374 375 self.max_file_size_limit = max_file_size_limit
375 376
376 377 def render_patchset(self, patchset, source_ref=None, target_ref=None):
@@ -475,6 +476,18 b' class DiffSet(object):'
475 476 hunkbit = self.parse_hunk(hunk, source_file, target_file)
476 477 hunkbit.filediff = filediff
477 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 491 return filediff
479 492
480 493 def parse_hunk(self, hunk, source_file, target_file):
@@ -507,6 +520,7 b' class DiffSet(object):'
507 520 self.parse_lines(before, after, source_file, target_file))
508 521 result.unified = self.as_unified(result.lines)
509 522 result.sideside = result.lines
523
510 524 return result
511 525
512 526 def parse_lines(self, before_lines, after_lines, source_file, target_file):
@@ -589,7 +603,10 b' class DiffSet(object):'
589 603 'new': 'n',
590 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 611 def get_line_tokens(self, line_text, line_number, file=None):
595 612 filenode = None
@@ -628,7 +645,9 b' class DiffSet(object):'
628 645 }.get(action, action)
629 646
630 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 651 def generator():
633 652 buf = []
634 653 for line in lines:
General Comments 0
You need to be logged in to leave comments. Login now