Show More
@@ -378,9 +378,8 b' class DiffSet(object):' | |||||
378 | source_node_getter=lambda filename: None, |
|
378 | source_node_getter=lambda filename: None, | |
379 | target_node_getter=lambda filename: None, |
|
379 | target_node_getter=lambda filename: None, | |
380 | source_nodes=None, target_nodes=None, |
|
380 | source_nodes=None, target_nodes=None, | |
381 |
|
|
381 | # files over this size will use fast highlighting | |
382 | # use fast highlighting |
|
382 | max_file_size_limit=150 * 1024, | |
383 | comments=None, |
|
|||
384 | ): |
|
383 | ): | |
385 |
|
384 | |||
386 | self.highlight_mode = highlight_mode |
|
385 | self.highlight_mode = highlight_mode | |
@@ -391,8 +390,6 b' class DiffSet(object):' | |||||
391 | self.target_nodes = target_nodes or {} |
|
390 | self.target_nodes = target_nodes or {} | |
392 | self.repo_name = repo_name |
|
391 | self.repo_name = repo_name | |
393 | self.source_repo_name = source_repo_name or repo_name |
|
392 | self.source_repo_name = source_repo_name or repo_name | |
394 | self.comments = comments or {} |
|
|||
395 | self.comments_store = self.comments.copy() |
|
|||
396 | self.max_file_size_limit = max_file_size_limit |
|
393 | self.max_file_size_limit = max_file_size_limit | |
397 |
|
394 | |||
398 | def render_patchset(self, patchset, source_ref=None, target_ref=None): |
|
395 | def render_patchset(self, patchset, source_ref=None, target_ref=None): | |
@@ -518,20 +515,6 b' class DiffSet(object):' | |||||
518 | hunkbit.target_file_path = target_file_path |
|
515 | hunkbit.target_file_path = target_file_path | |
519 | filediff.hunks.append(hunkbit) |
|
516 | filediff.hunks.append(hunkbit) | |
520 |
|
517 | |||
521 | left_comments = {} |
|
|||
522 | if source_file_path in self.comments_store: |
|
|||
523 | for lineno, comments in self.comments_store[source_file_path].items(): |
|
|||
524 | left_comments[lineno] = comments |
|
|||
525 |
|
||||
526 | if target_file_path in self.comments_store: |
|
|||
527 | for lineno, comments in self.comments_store[target_file_path].items(): |
|
|||
528 | left_comments[lineno] = comments |
|
|||
529 |
|
||||
530 | # left comments are one that we couldn't place in diff lines. |
|
|||
531 | # could be outdated, or the diff changed and this line is no |
|
|||
532 | # longer available |
|
|||
533 | filediff.left_comments = left_comments |
|
|||
534 |
|
||||
535 | return filediff |
|
518 | return filediff | |
536 |
|
519 | |||
537 | def parse_hunk(self, hunk, source_file, target_file): |
|
520 | def parse_hunk(self, hunk, source_file, target_file): |
@@ -28,7 +28,7 b'' | |||||
28 |
|
28 | |||
29 | <div class="meta"> |
|
29 | <div class="meta"> | |
30 | <div class="comment-type-label"> |
|
30 | <div class="comment-type-label"> | |
31 | <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}"> |
|
31 | <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}" title="line: ${comment.line_no}"> | |
32 | % if comment.comment_type == 'todo': |
|
32 | % if comment.comment_type == 'todo': | |
33 | % if comment.resolved: |
|
33 | % if comment.resolved: | |
34 | <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}"> |
|
34 | <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}"> |
@@ -223,10 +223,22 b' collapse_all = len(diffset.files) > coll' | |||||
223 | %endif |
|
223 | %endif | |
224 | %endfor |
|
224 | %endfor | |
225 |
|
|
225 | ||
|
226 | <% unmatched_comments = (inline_comments or {}).get(filediff.patch['filename'], {}) %> | |||
|
227 | ||||
226 | ## outdated comments that do not fit into currently displayed lines |
|
228 | ## outdated comments that do not fit into currently displayed lines | |
227 |
% for lineno, comments in |
|
229 | % for lineno, comments in unmatched_comments.items(): | |
228 |
|
230 | |||
229 | %if c.diffmode == 'unified': |
|
231 | %if c.diffmode == 'unified': | |
|
232 | % if loop.index == 0: | |||
|
233 | <tr class="cb-hunk"> | |||
|
234 | <td colspan="3"></td> | |||
|
235 | <td> | |||
|
236 | <div> | |||
|
237 | ${_('Unmatched inline comments below')} | |||
|
238 | </div> | |||
|
239 | </td> | |||
|
240 | </tr> | |||
|
241 | % endif | |||
230 | <tr class="cb-line"> |
|
242 | <tr class="cb-line"> | |
231 | <td class="cb-data cb-context"></td> |
|
243 | <td class="cb-data cb-context"></td> | |
232 | <td class="cb-lineno cb-context"></td> |
|
244 | <td class="cb-lineno cb-context"></td> | |
@@ -236,6 +248,16 b' collapse_all = len(diffset.files) > coll' | |||||
236 | </td> |
|
248 | </td> | |
237 | </tr> |
|
249 | </tr> | |
238 | %elif c.diffmode == 'sideside': |
|
250 | %elif c.diffmode == 'sideside': | |
|
251 | % if loop.index == 0: | |||
|
252 | <tr class="cb-hunk"> | |||
|
253 | <td colspan="2"></td> | |||
|
254 | <td class="cb-line" colspan="6"> | |||
|
255 | <div> | |||
|
256 | ${_('Unmatched comments below')} | |||
|
257 | </div> | |||
|
258 | </td> | |||
|
259 | </tr> | |||
|
260 | % endif | |||
239 | <tr class="cb-line"> |
|
261 | <tr class="cb-line"> | |
240 | <td class="cb-data cb-context"></td> |
|
262 | <td class="cb-data cb-context"></td> | |
241 | <td class="cb-lineno cb-context"></td> |
|
263 | <td class="cb-lineno cb-context"></td> | |
@@ -512,18 +534,20 b' from rhodecode.lib.diffs import NEW_FILE' | |||||
512 | </%def> |
|
534 | </%def> | |
513 |
|
535 | |||
514 | <%! |
|
536 | <%! | |
515 | def get_comments_for(comments, filename, line_version, line_number): |
|
537 | def get_comments_for(diff_type, comments, filename, line_version, line_number): | |
516 | if hasattr(filename, 'unicode_path'): |
|
538 | if hasattr(filename, 'unicode_path'): | |
517 | filename = filename.unicode_path |
|
539 | filename = filename.unicode_path | |
518 |
|
540 | |||
519 | if not isinstance(filename, basestring): |
|
541 | if not isinstance(filename, basestring): | |
520 | return None |
|
542 | return None | |
521 |
|
543 | |||
522 | line_key = '{}{}'.format(line_version, line_number) |
|
544 | line_key = '{}{}'.format(line_version, line_number) ## e.g o37, n12 | |
|
545 | ||||
523 | if comments and filename in comments: |
|
546 | if comments and filename in comments: | |
524 | file_comments = comments[filename] |
|
547 | file_comments = comments[filename] | |
525 | if line_key in file_comments: |
|
548 | if line_key in file_comments: | |
526 |
|
|
549 | data = file_comments.pop(line_key) | |
|
550 | return data | |||
527 | %> |
|
551 | %> | |
528 |
|
552 | |||
529 | <%def name="render_hunk_lines_sideside(hunk, use_comments=False, inline_comments=None)"> |
|
553 | <%def name="render_hunk_lines_sideside(hunk, use_comments=False, inline_comments=None)"> | |
@@ -542,16 +566,17 b' def get_comments_for(comments, filename,' | |||||
542 | data-line-no="${line.original.lineno}" |
|
566 | data-line-no="${line.original.lineno}" | |
543 | > |
|
567 | > | |
544 | <div> |
|
568 | <div> | |
545 | <% loc = None %> |
|
569 | ||
|
570 | <% line_old_comments = None %> | |||
546 | %if line.original.get_comment_args: |
|
571 | %if line.original.get_comment_args: | |
547 | <% loc = get_comments_for(inline_comments, *line.original.get_comment_args) %> |
|
572 | <% line_old_comments = get_comments_for('side-by-side', inline_comments, *line.original.get_comment_args) %> | |
548 | %endif |
|
573 | %endif | |
549 | %if loc: |
|
574 | %if line_old_comments: | |
550 | <% has_outdated = any([x.outdated for x in loc]) %> |
|
575 | <% has_outdated = any([x.outdated for x in line_old_comments]) %> | |
551 | % if has_outdated: |
|
576 | % if has_outdated: | |
552 | <i title="${_('comments including outdated')}:${len(loc)}" class="icon-comment_toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
577 | <i title="${_('comments including outdated')}:${len(line_old_comments)}" class="icon-comment_toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
553 | % else: |
|
578 | % else: | |
554 | <i title="${_('comments')}: ${len(loc)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> |
|
579 | <i title="${_('comments')}: ${len(line_old_comments)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
555 | % endif |
|
580 | % endif | |
556 | %endif |
|
581 | %endif | |
557 | </div> |
|
582 | </div> | |
@@ -574,8 +599,8 b' def get_comments_for(comments, filename,' | |||||
574 | %endif |
|
599 | %endif | |
575 | <span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span> |
|
600 | <span class="cb-code">${line.original.action} ${line.original.content or '' | n}</span> | |
576 |
|
601 | |||
577 | %if use_comments and line.original.lineno and loc: |
|
602 | %if use_comments and line.original.lineno and line_old_comments: | |
578 | ${inline_comments_container(loc, inline_comments)} |
|
603 | ${inline_comments_container(line_old_comments, inline_comments)} | |
579 | %endif |
|
604 | %endif | |
580 |
|
605 | |||
581 | </td> |
|
606 | </td> | |
@@ -585,16 +610,16 b' def get_comments_for(comments, filename,' | |||||
585 | <div> |
|
610 | <div> | |
586 |
|
611 | |||
587 | %if line.modified.get_comment_args: |
|
612 | %if line.modified.get_comment_args: | |
588 |
<% l |
|
613 | <% line_new_comments = get_comments_for('side-by-side', inline_comments, *line.modified.get_comment_args) %> | |
589 | %else: |
|
614 | %else: | |
590 |
<% l |
|
615 | <% line_new_comments = None%> | |
591 | %endif |
|
616 | %endif | |
592 |
%if l |
|
617 | %if line_new_comments: | |
593 |
<% has_outdated = any([x.outdated for x in l |
|
618 | <% has_outdated = any([x.outdated for x in line_new_comments]) %> | |
594 | % if has_outdated: |
|
619 | % if has_outdated: | |
595 |
<i title="${_('comments including outdated')}:${len(l |
|
620 | <i title="${_('comments including outdated')}:${len(line_new_comments)}" class="icon-comment_toggle" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
596 | % else: |
|
621 | % else: | |
597 |
<i title="${_('comments')}: ${len(l |
|
622 | <i title="${_('comments')}: ${len(line_new_comments)}" class="icon-comment" onclick="return Rhodecode.comments.toggleLineComments(this)"></i> | |
598 | % endif |
|
623 | % endif | |
599 | %endif |
|
624 | %endif | |
600 | </div> |
|
625 | </div> | |
@@ -616,8 +641,8 b' def get_comments_for(comments, filename,' | |||||
616 | ${render_add_comment_button()} |
|
641 | ${render_add_comment_button()} | |
617 | %endif |
|
642 | %endif | |
618 | <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span> |
|
643 | <span class="cb-code">${line.modified.action} ${line.modified.content or '' | n}</span> | |
619 |
%if use_comments and line.modified.lineno and l |
|
644 | %if use_comments and line.modified.lineno and line_new_comments: | |
620 |
${inline_comments_container(l |
|
645 | ${inline_comments_container(line_new_comments, inline_comments)} | |
621 | %endif |
|
646 | %endif | |
622 | </td> |
|
647 | </td> | |
623 | </tr> |
|
648 | </tr> | |
@@ -639,7 +664,7 b' def get_comments_for(comments, filename,' | |||||
639 | <div> |
|
664 | <div> | |
640 |
|
665 | |||
641 | %if comments_args: |
|
666 | %if comments_args: | |
642 | <% comments = get_comments_for(inline_comments, *comments_args) %> |
|
667 | <% comments = get_comments_for('unified', inline_comments, *comments_args) %> | |
643 | %else: |
|
668 | %else: | |
644 | <% comments = None%> |
|
669 | <% comments = None%> | |
645 | %endif |
|
670 | %endif |
General Comments 0
You need to be logged in to leave comments.
Login now