Changeset - 4034992774fa
[Not reviewed]
default
0 5 0
Mads Kiilerich - 9 years ago 2016-09-06 00:51:18
madski@unity3d.com
diffs: fold diff_block_simple (used by PR and compare) into diff_block

Change to using the same datamodel and enjoy the reduced amount of code
duplication.
5 files changed with 27 insertions and 44 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/compare.py
Show inline comments
 
@@ -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')
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -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
kallithea/templates/changeset/diff_block.html
Show inline comments
 
@@ -15,22 +15,6 @@
 
</div>
 
</%def>
 

	
 
<%def name="diff_block_simple(files, changes)">
 
<div class="diff-collapse">
 
    <span target="${'diff-container-%s' % (id(changes))}" class="diff-collapse-button">&uarr; ${_('Collapse Diff')} &uarr;</span>
 
</div>
 
<div class="diff-container" id="${'diff-container-%s' % (id(changes))}">
 
  %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
 
</div>
 
</%def>
 

	
 
<%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)"
kallithea/templates/compare/compare_diff.html
Show inline comments
 
@@ -57,9 +57,9 @@ ${self.repo_context_bar('changelog')}
 
                <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
 

	
 
                % 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')}
 

	
 
                </div>
 
                <div class="cs_files">
 
                  %if not c.files:
 
                  %if not c.file_diff_data:
 
                     <span class="empty_data">${_('No files')}</span>
 
                  %endif
 
                  %for fid, op, f, stat in c.files:
 
                  %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
 
                    <div class="cs_${op}">
 
                      <div class="node">
 
                          <i class="icon-diff-${op}"></i>
 
                          ${h.link_to(h.safe_unicode(f), '#' + fid)}
 
                          ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
 
                      </div>
 
                      <div class="changes">${h.fancy_file_stats(stat)}</div>
 
                      <div class="changes">${h.fancy_file_stats(stats)}</div>
 
                    </div>
 
                  %endfor
 
                  %if c.limited_diff:
 
                    <h5>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff')}</a></h5>
 
                    <h5>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff anyway')}</a></h5>
 
                  %endif
 
                </div>
 
         </div>
 
@@ -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:
 
          <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff')}</a></h4>
 
        % endif
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -324,23 +324,23 @@ ${self.repo_context_bar('showpullrequest
 
              <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
 

	
 
              % 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
 

	
 
              </div>
 
              <div class="cs_files">
 
                %if not c.files:
 
                %if not c.file_diff_data:
 
                   <span class="empty_data">${_('No files')}</span>
 
                %endif
 
                %for fid, op, f, stat in c.files:
 
                %for fid, (url_fid, op, path, diff, stats) in c.file_diff_data.iteritems():
 
                    <div class="cs_${op}">
 
                      <div class="node">
 
                          <i class="icon-diff-${op}"></i>
 
                          ${h.link_to(h.safe_unicode(f),'#' + fid)}
 
                          ${h.link_to(h.safe_unicode(path), '#%s' % fid)}
 
                      </div>
 
                      <div class="changes">${h.fancy_file_stats(stat)}</div>
 
                      <div class="changes">${h.fancy_file_stats(stats)}</div>
 
                    </div>
 
                %endfor
 
                %if c.limited_diff:
 
@@ -365,7 +365,8 @@ ${self.repo_context_bar('showpullrequest
 
    <div class="commentable-diff">
 
    <%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:
 
      <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff anyway')}</a></h4>
 
    % endif
0 comments (0 inline, 0 general)