diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py --- a/rhodecode/controllers/changeset.py +++ b/rhodecode/controllers/changeset.py @@ -32,7 +32,7 @@ from pylons.i18n.translation import _ from pylons.controllers.util import redirect from rhodecode.lib import auth -from rhodecode.lib import diffs +from rhodecode.lib import diffs, codeblocks from rhodecode.lib.auth import ( LoginRequired, HasRepoPermissionAnyDecorator, NotAnonymous) from rhodecode.lib.base import BaseRepoController, render @@ -242,28 +242,32 @@ class ChangesetController(BaseRepoContro file_limit = self.cut_off_limit_file diff_processor = diffs.DiffProcessor( - _diff, format='gitdiff', diff_limit=diff_limit, + _diff, format='newdiff', diff_limit=diff_limit, file_limit=file_limit, show_full_diff=fulldiff) commit_changes = OrderedDict() if method == 'show': _parsed = diff_processor.prepare() c.limited_diff = isinstance(_parsed, diffs.LimitedDiffContainer) - for f in _parsed: - c.files.append(f) - st = f['stats'] - c.lines_added += st['added'] - c.lines_deleted += st['deleted'] - fid = h.FID(commit.raw_id, f['filename']) - diff = diff_processor.as_html(enable_comments=enable_comments, - parsed_lines=[f]) - commit_changes[fid] = [ - commit1.raw_id, commit2.raw_id, - f['operation'], f['filename'], diff, st, f] + + _parsed = diff_processor.prepare() + + def _node_getter(commit): + def get_node(fname): + try: + return commit.get_node(fname) + except NodeDoesNotExistError: + return None + return get_node + + diffset = codeblocks.DiffSet( + source_node_getter=_node_getter(commit1), + target_node_getter=_node_getter(commit2), + ).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 = diff_processor.as_raw() - commit_changes[''] = [None, None, None, None, diff, None, None] - c.changes[commit.raw_id] = commit_changes + c.changes[commit.raw_id] = [None, None, None, None, diff, None, None] # sort comments by how they were generated c.comments = sorted(c.comments, key=lambda x: x.comment_id) diff --git a/rhodecode/templates/changeset/changeset.html b/rhodecode/templates/changeset/changeset.html --- a/rhodecode/templates/changeset/changeset.html +++ b/rhodecode/templates/changeset/changeset.html @@ -42,12 +42,12 @@ ${_('Parent')} - | + | ${_('Child')} - +
${_('Description')}: @@ -59,7 +59,7 @@
- + %if c.statuses:
@@ -73,20 +73,20 @@
%endif - +
${_('References')}:
- + %if c.commit.merge: ${_('merge')} %endif - + %if h.is_hg(c.rhodecode_repo): %for book in c.commit.bookmarks: @@ -94,13 +94,13 @@ %endfor %endif - + %for tag in c.commit.tags: ${tag} %endfor - + %if c.commit.branch: ${h.shorter(c.commit.branch)} @@ -119,22 +119,22 @@ ${_('Raw Diff')} - | + | ${_('Patch Diff')} - | + | ${_('Download Diff')} - | + | ${c.ignorews_url(request.GET)} - | + | ${c.context_url(request.GET)}
- +
${_('Comments')}: @@ -155,9 +155,9 @@
- + - + -
- - ${_('Browse files')} | - - ${_('Expand All')} | ${_('Collapse All')} - -

- ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)} -

-
- - -
- - %if not c.files: -

${_('No files')}

- %endif +
+ ${cbdiffs.render_diffset_menu()} - - %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[c.commit.raw_id].iteritems(): - - - - - - - - - - - - - - - - - - %endfor -
- - - - - - -
${h.fancy_file_stats(stats)}
-
- -
-
-
-
-
-
- ${diff|n} - % if file and file["is_limited_diff"]: - % if file["exceeds_limit"]: - ${diff_block.file_message()} - % else: -
${_('Diff was truncated. File content available only in full diff.')} ${_('Show full diff')}
- % endif - % endif -
-
-
-
+ <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/> + ${cbdiffs.render_diffset(c.changes[c.commit.raw_id], commit=c.commit)} +
- % if c.limited_diff: - ${diff_block.changeset_message()} - % endif - ## template for inline comment form <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> ${comment.comment_inline_form()} diff --git a/rhodecode/templates/changeset/changeset_range.html b/rhodecode/templates/changeset/changeset_range.html --- a/rhodecode/templates/changeset/changeset_range.html +++ b/rhodecode/templates/changeset/changeset_range.html @@ -49,78 +49,23 @@ ${self.breadcrumbs_links()} - -
- ##CS - <%include file="../compare/compare_commits.html"/> - ## FILES -
- - ${_('Expand All')} | ${_('Collapse All')} - -

- ${diff_block.diff_summary_text(len(c.files), c.lines_added, c.lines_deleted, c.limited_diff)} -

-
-
- -
- +
+ ##CS + <%include file="../compare/compare_commits.html"/> +
+ ${cbdiffs.render_diffset_menu()} + <%namespace name="cbdiffs" file="/codeblocks/diffs.html"/> <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> <%namespace name="diff_block" file="/changeset/diff_block.html"/> - %for cs in c.commit_ranges: -
- - - %for FID, (cs1, cs2, change, path, diff, stats, file) in c.changes[cs.raw_id].iteritems(): - - - - - - - - - - - - - - - - - - %endfor - %endfor -
- ${'r%s:%s' % (cs.revision,h.short_id(cs.raw_id))} | - ${h.age_component(cs.date)} -
- - - - - - -
${h.fancy_file_stats(stats)}
-
-
-
-
- ${diff|n} -
-
-
-
+ %for commit in c.commit_ranges: + ${cbdifss.render_diffset( + diffset=c.changes[commit.raw_id], + collapse_when_files_over=5, + commit=commit, + )} + %endfor + +
-## end summary detail - - \ No newline at end of file + diff --git a/rhodecode/templates/codeblocks/diffs.html b/rhodecode/templates/codeblocks/diffs.html --- a/rhodecode/templates/codeblocks/diffs.html +++ b/rhodecode/templates/codeblocks/diffs.html @@ -417,4 +417,4 @@ from rhodecode.lib.diffs import NEW_FILE - \ No newline at end of file +