Changeset - 410934dd09f4
[Not reviewed]
default
0 5 0
Thomas De Schampheleire - 5 years ago 2020-10-30 22:38:39
thomas.de_schampheleire@nokia.com
diffs: remove unused argument enable_comments and class no-comment

enable_comments was only used to set/not-set the 'no-comment' CSS class.
While this class was emitted, no CSS rule nor any JavaScript logic was
actually using it. Last real usage of that class was removed with commit
e87baa8f1c5bd2488aefc23b95c0db3a04bc8431.

Cleanup the code by not emitting 'no-comment' and remove the
'enable_comments' flag.
5 files changed with 10 insertions and 16 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/changeset.py
Show inline comments
 
@@ -182,11 +182,9 @@ class ChangesetController(BaseRepoContro
 
        c.fulldiff = request.GET.get('fulldiff') # for reporting number of changed files
 
        # get ranges of revisions if preset
 
        rev_range = revision.split('...')[:2]
 
        enable_comments = True
 
        c.cs_repo = c.db_repo
 
        try:
 
            if len(rev_range) == 2:
 
                enable_comments = False
 
                rev_start = rev_range[0]
 
                rev_end = rev_range[1]
 
                rev_ranges = c.db_repo_scm_instance.get_changesets(start=rev_start,
 
@@ -259,7 +257,7 @@ class ChangesetController(BaseRepoContro
 
                    filename = f['filename']
 
                    fid = h.FID(changeset.raw_id, filename)
 
                    url_fid = h.FID('', filename)
 
                    html_diff = diffs.as_html(enable_comments=enable_comments, parsed_lines=[f])
 
                    html_diff = diffs.as_html(parsed_lines=[f])
 
                    file_diff_data.append((fid, url_fid, f['operation'], f['old_filename'], filename, html_diff, st))
 
            else:
 
                # downloads/raw we only need RAW diff nothing else
kallithea/controllers/compare.py
Show inline comments
 
@@ -182,7 +182,7 @@ class CompareController(BaseRepoControll
 
            c.lines_deleted += st['deleted']
 
            filename = f['filename']
 
            fid = h.FID('', filename)
 
            html_diff = diffs.as_html(enable_comments=False, parsed_lines=[f])
 
            html_diff = diffs.as_html(parsed_lines=[f])
 
            c.file_diff_data.append((fid, None, f['operation'], f['old_filename'], filename, html_diff, st))
 

	
 
        return render('compare/compare_diff.html')
kallithea/controllers/files.py
Show inline comments
 
@@ -642,8 +642,7 @@ class FilesController(BaseRepoController
 
                                         filenode_new=node2,
 
                                         diff_limit=diff_limit,
 
                                         ignore_whitespace=ignore_whitespace_diff,
 
                                         line_context=diff_context_size,
 
                                         enable_comments=False)
 
                                         line_context=diff_context_size)
 
            c.file_diff_data = [(fid, fid, op, a_path, node2.path, diff, st)]
 
            return render('files/file_diff.html')
 

	
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -595,7 +595,7 @@ class PullrequestsController(BaseRepoCon
 
            c.lines_deleted += st['deleted']
 
            filename = f['filename']
 
            fid = h.FID('', filename)
 
            html_diff = diffs.as_html(enable_comments=True, parsed_lines=[f])
 
            html_diff = diffs.as_html(parsed_lines=[f])
 
            c.file_diff_data.append((fid, None, f['operation'], f['old_filename'], filename, html_diff, st))
 

	
 
        # inline comments
kallithea/lib/diffs.py
Show inline comments
 
@@ -66,7 +66,7 @@ def _safe_id(idstring):
 
def as_html(table_class='code-difftable', line_class='line',
 
            old_lineno_class='lineno old', new_lineno_class='lineno new',
 
            no_lineno_class='lineno',
 
            code_class='code', enable_comments=False, parsed_lines=None):
 
            code_class='code', parsed_lines=None):
 
    """
 
    Return given diff as html table with customized css classes
 
    """
 
@@ -141,10 +141,8 @@ def as_html(table_class='code-difftable'
 
                ###########################################################
 
                # CODE
 
                ###########################################################
 
                comments = '' if enable_comments else 'no-comment'
 
                _html.append('''\t<td class="%(cc)s %(inc)s">''' % {
 
                _html.append('''\t<td class="%(cc)s">''' % {
 
                    'cc': code_class,
 
                    'inc': comments
 
                })
 
                _html.append('''\n\t\t<div class="add-bubble"><div>&nbsp;</div></div><pre>%(code)s</pre>\n''' % {
 
                    'code': change['line']
 
@@ -163,16 +161,15 @@ def wrap_to_table(html):
 
    DiffProcessor returns."""
 
    return '''\
 
              <table class="code-difftable">
 
                <tr class="line no-comment">
 
                <tr class="line">
 
                <td class="lineno new"></td>
 
                <td class="code no-comment"><pre>%s</pre></td>
 
                <td class="code"><pre>%s</pre></td>
 
                </tr>
 
              </table>''' % html
 

	
 

	
 
def wrapped_diff(filenode_old, filenode_new, diff_limit=None,
 
                ignore_whitespace=True, line_context=3,
 
                enable_comments=False):
 
                ignore_whitespace=True, line_context=3):
 
    """
 
    Returns a file diff wrapped into a table.
 
    Checks for diff_limit and presents a message if the diff is too big.
 
@@ -199,7 +196,7 @@ def wrapped_diff(filenode_old, filenode_
 
            op = f['operation']
 
            a_path = f['old_filename']
 

	
 
        html_diff = as_html(parsed_lines=diff_processor.parsed, enable_comments=enable_comments)
 
        html_diff = as_html(parsed_lines=diff_processor.parsed)
 
        stats = diff_processor.stat()
 

	
 
    else:
0 comments (0 inline, 0 general)