diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -44,7 +44,7 @@ from kallithea.model.db import Repositor from kallithea.lib.diffs import LimitedDiffContainer from kallithea.controllers.changeset import _ignorews_url, _context_url from kallithea.lib.graphmod import graph_data -from kallithea.lib.compat import json +from kallithea.lib.compat import json, OrderedDict log = logging.getLogger(__name__) @@ -277,8 +277,7 @@ class CompareController(BaseRepoControll if isinstance(_parsed, LimitedDiffContainer): c.limited_diff = True - c.files = [] - c.changes = {} + c.file_diff_data = OrderedDict() c.lines_added = 0 c.lines_deleted = 0 for f in _parsed: @@ -287,8 +286,8 @@ class CompareController(BaseRepoControll c.lines_deleted += st['deleted'] filename = f['filename'] fid = h.FID('', filename) - c.files.append([fid, f['operation'], filename, f['stats']]) - htmldiff = diff_processor.as_html(enable_comments=False, parsed_lines=[f]) - c.changes[fid] = [f['operation'], filename, htmldiff] + diff = diff_processor.as_html(enable_comments=False, + parsed_lines=[f]) + c.file_diff_data[fid] = (None, f['operation'], filename, diff, st) return render('compare/compare_diff.html') diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -35,7 +35,7 @@ from pylons.i18n.translation import _ from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest from kallithea.lib.vcs.utils.hgcompat import unionrepo -from kallithea.lib.compat import json +from kallithea.lib.compat import json, OrderedDict from kallithea.lib.base import BaseRepoController, render from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator, \ NotAnonymous @@ -695,8 +695,7 @@ class PullrequestsController(BaseRepoCon if isinstance(_parsed, LimitedDiffContainer): c.limited_diff = True - c.files = [] - c.changes = {} + c.file_diff_data = OrderedDict() c.lines_added = 0 c.lines_deleted = 0 @@ -706,10 +705,9 @@ class PullrequestsController(BaseRepoCon c.lines_deleted += st['deleted'] filename = f['filename'] fid = h.FID('', filename) - c.files.append([fid, f['operation'], filename, f['stats']]) - htmldiff = diff_processor.as_html(enable_comments=True, - parsed_lines=[f]) - c.changes[fid] = [f['operation'], filename, htmldiff] + diff = diff_processor.as_html(enable_comments=True, + parsed_lines=[f]) + c.file_diff_data[fid] = (None, f['operation'], filename, diff, st) # inline comments c.inline_cnt = 0 diff --git a/kallithea/templates/changeset/diff_block.html b/kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html +++ b/kallithea/templates/changeset/diff_block.html @@ -15,22 +15,6 @@ -<%def name="diff_block_simple(files, changes)"> -
- ↑ ${_('Collapse Diff')} ↑ -
-
- %for fid, ch, f, stat in files: - <% - op, filename, diff = changes[fid] - %> - ${diff_block_diffblock(h.FID('', filename), None, op, filename, diff, - c.a_repo.repo_name, c.a_rev, c.a_ref_type, c.a_ref_name, - c.cs_repo.repo_name, c.cs_rev, c.cs_ref_type, c.cs_ref_name)} - %endfor -
- - <%def name="diff_block_diffblock(id_fid, url_fid, op, filename, diff, a_repo_name, a_rev, a_ref_type, a_ref_name, cs_repo_name, cs_rev, cs_ref_type, cs_ref_name)" diff --git a/kallithea/templates/compare/compare_diff.html b/kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html +++ b/kallithea/templates/compare/compare_diff.html @@ -57,9 +57,9 @@ ${self.repo_context_bar('changelog')}
% if c.limited_diff: - ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}: + ${ungettext('%s file changed', '%s files changed', len(c.file_diff_data)) % len(c.file_diff_data)}: % else: - ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.files)) % (len(c.files),c.lines_added,c.lines_deleted)}: + ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.file_diff_data)) % (len(c.file_diff_data),c.lines_added,c.lines_deleted)}: %endif ${c.ignorews_url(request.GET)} @@ -67,20 +67,20 @@ ${self.repo_context_bar('changelog')}
- %if not c.files: + %if not c.file_diff_data: ${_('No files')} %endif - %for fid, op, f, stat in c.files: + %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
- ${h.link_to(h.safe_unicode(f), '#' + fid)} + ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
-
${h.fancy_file_stats(stat)}
+
${h.fancy_file_stats(stats)}
%endfor %if c.limited_diff: -
${_('Changeset was too big and was cut off...')} ${_('Show full diff')}
+
${_('Changeset was too big and was cut off...')} ${_('Show full diff anyway')}
%endif
@@ -88,7 +88,8 @@ ${self.repo_context_bar('changelog')} ## diff block <%namespace name="diff_block" file="/changeset/diff_block.html"/> ${diff_block.diff_block_js()} - ${diff_block.diff_block_simple(c.files, c.changes)} + ${diff_block.diff_block(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name, c.a_rev, + c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev, c.file_diff_data)} % if c.limited_diff:

${_('Changeset was too big and was cut off...')} ${_('Show full diff')}

% endif diff --git a/kallithea/templates/pullrequests/pullrequest_show.html b/kallithea/templates/pullrequests/pullrequest_show.html --- a/kallithea/templates/pullrequests/pullrequest_show.html +++ b/kallithea/templates/pullrequests/pullrequest_show.html @@ -324,23 +324,23 @@ ${self.repo_context_bar('showpullrequest
% if c.limited_diff: - ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}: + ${ungettext('%s file changed', '%s files changed', len(c.file_diff_data)) % len(c.file_diff_data)}: % else: - ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.files)) % (len(c.files),c.lines_added,c.lines_deleted)}: + ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.file_diff_data)) % (len(c.file_diff_data),c.lines_added,c.lines_deleted)}: %endif
- %if not c.files: + %if not c.file_diff_data: ${_('No files')} %endif - %for fid, op, f, stat in c.files: + %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
- ${h.link_to(h.safe_unicode(f),'#' + fid)} + ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
-
${h.fancy_file_stats(stat)}
+
${h.fancy_file_stats(stats)}
%endfor %if c.limited_diff: @@ -365,7 +365,8 @@ ${self.repo_context_bar('showpullrequest
<%namespace name="diff_block" file="/changeset/diff_block.html"/> ${diff_block.diff_block_js()} - ${diff_block.diff_block_simple(c.files, c.changes)} + ${diff_block.diff_block(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name, c.a_rev, + c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev, c.file_diff_data)} % if c.limited_diff:

${_('Changeset was too big and was cut off...')} ${_('Show full diff anyway')}

% endif