# HG changeset patch # User Marcin Kuzminski # Date 2017-11-17 17:37:50 # Node ID edf29c73b5e19d6247cd06e41fbedb05a0a7ca79 # Parent e331d3e69fc1215a9a3eec1f45cb1c8fc65b7bc6 comments: place the left over comments (outdated/misplaced) to the left or right pane. So we don't loose the original context where they were placed. diff --git a/rhodecode/lib/codeblocks.py b/rhodecode/lib/codeblocks.py --- a/rhodecode/lib/codeblocks.py +++ b/rhodecode/lib/codeblocks.py @@ -402,6 +402,7 @@ class DiffSet(object): return diffset _lexer_cache = {} + def _get_lexer_for_filename(self, filename, filenode=None): # cached because we might need to call it twice for source/target if filename not in self._lexer_cache: @@ -501,6 +502,9 @@ class DiffSet(object): if target_file_path in self.comments_store: for lineno, comments in self.comments_store[target_file_path].items(): left_comments[lineno] = comments + # left comments are one that we couldn't place in diff lines. + # could be outdated, or the diff changed and this line is no + # longer available filediff.left_comments = left_comments return filediff @@ -608,11 +612,11 @@ class DiffSet(object): return lines - def get_comments_for(self, version, file, line_number): - if hasattr(file, 'unicode_path'): - file = file.unicode_path + def get_comments_for(self, version, filename, line_number): + if hasattr(filename, 'unicode_path'): + filename = filename.unicode_path - if not isinstance(file, basestring): + if not isinstance(filename, basestring): return None line_key = { @@ -620,8 +624,8 @@ class DiffSet(object): 'new': 'n', }[version] + str(line_number) - if file in self.comments_store: - file_comments = self.comments_store[file] + if filename in self.comments_store: + file_comments = self.comments_store[filename] if line_key in file_comments: return file_comments.pop(line_key) diff --git a/rhodecode/templates/codeblocks/diffs.mako b/rhodecode/templates/codeblocks/diffs.mako --- a/rhodecode/templates/codeblocks/diffs.mako +++ b/rhodecode/templates/codeblocks/diffs.mako @@ -235,12 +235,18 @@ collapse_all = len(diffset.files) > coll - + + % if lineno.startswith('o'): + ${inline_comments_container(comments)} + % endif + - ${inline_comments_container(comments)} + % if lineno.startswith('n'): + ${inline_comments_container(comments)} + % endif %endif