diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -267,8 +267,10 @@ class ChangesetController(BaseRepoContro repo_name=c.repo_name, source_node_getter=_node_getter(commit1), target_node_getter=_node_getter(commit2), - comments=inline_comments - ).render_patchset(_parsed, commit1.raw_id, commit2.raw_id) + comments=inline_comments) + diffset = diffset.render_patchset( + _parsed, commit1.raw_id, commit2.raw_id) + c.changes[commit.raw_id] = diffset else: # downloads/raw we only need RAW diff nothing else diff --git a/rhodecode/controllers/compare.py b/rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py +++ b/rhodecode/controllers/compare.py @@ -271,11 +271,13 @@ class CompareController(BaseRepoControll return None return get_node - c.diffset = codeblocks.DiffSet( + diffset = codeblocks.DiffSet( repo_name=source_repo.repo_name, source_node_getter=_node_getter(source_commit), target_node_getter=_node_getter(target_commit), - ).render_patchset(_parsed, source_ref, target_ref) + ) + c.diffset = diffset.render_patchset( + _parsed, source_ref, target_ref) c.preview_mode = merge c.source_commit = source_commit diff --git a/rhodecode/lib/codeblocks.py b/rhodecode/lib/codeblocks.py --- a/rhodecode/lib/codeblocks.py +++ b/rhodecode/lib/codeblocks.py @@ -471,31 +471,29 @@ class DiffSet(object): source_file_type = source_lexer.name target_file_type = target_lexer.name - op_hunks = patch['chunks'][0] - hunks = patch['chunks'][1:] - filediff = AttributeDict({ 'source_file_path': source_file_path, 'target_file_path': target_file_path, 'source_filenode': source_filenode, 'target_filenode': target_filenode, - 'hunks': [], 'source_file_type': target_file_type, 'target_file_type': source_file_type, - 'patch': patch, + 'patch': {'filename': patch['filename'], 'stats': patch['stats']}, + 'operation': patch['operation'], 'source_mode': patch['stats']['old_mode'], 'target_mode': patch['stats']['new_mode'], 'limited_diff': isinstance(patch, LimitedDiffContainer), + 'hunks': [], 'diffset': self, }) - for hunk in hunks: + for hunk in patch['chunks'][1:]: hunkbit = self.parse_hunk(hunk, source_file, target_file) - hunkbit.filediff = filediff + hunkbit.source_file_path = source_file_path + hunkbit.target_file_path = target_file_path filediff.hunks.append(hunkbit) left_comments = {} - if source_file_path in self.comments_store: for lineno, comments in self.comments_store[source_file_path].items(): left_comments[lineno] = comments @@ -503,8 +501,8 @@ 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 + filediff.left_comments = left_comments - filediff.left_comments = left_comments return filediff def parse_hunk(self, hunk, source_file, target_file): @@ -519,6 +517,7 @@ class DiffSet(object): before, after = [], [] for line in hunk['lines']: + if line['action'] == 'unmod': result.lines.extend( self.parse_lines(before, after, source_file, target_file)) @@ -567,7 +566,8 @@ class DiffSet(object): before_tokens = [('nonl', before['line'])] else: before_tokens = self.get_line_tokens( - line_text=before['line'], line_number=before['old_lineno'], + line_text=before['line'], + line_number=before['old_lineno'], file=source_file) original.lineno = before['old_lineno'] original.content = before['line'] 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 @@ -147,14 +147,14 @@ collapse_all = len(diffset.files) > coll %for i, filediff in enumerate(diffset.files): <% - lines_changed = filediff['patch']['stats']['added'] + filediff['patch']['stats']['deleted'] + lines_changed = filediff.patch['stats']['added'] + filediff.patch['stats']['deleted'] over_lines_changed_limit = lines_changed > lines_changed_limit %>