changeset 8711:410934dd09f4

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.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Fri, 30 Oct 2020 22:38:39 +0100
parents 77f13ea8ad3b
children 1f8eaa4c1dff
files kallithea/controllers/changeset.py kallithea/controllers/compare.py kallithea/controllers/files.py kallithea/controllers/pullrequests.py kallithea/lib/diffs.py
diffstat 5 files changed, 10 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/changeset.py	Wed Oct 25 09:10:30 2017 +0200
+++ b/kallithea/controllers/changeset.py	Fri Oct 30 22:38:39 2020 +0100
@@ -182,11 +182,9 @@
         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 @@
                     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
--- a/kallithea/controllers/compare.py	Wed Oct 25 09:10:30 2017 +0200
+++ b/kallithea/controllers/compare.py	Fri Oct 30 22:38:39 2020 +0100
@@ -182,7 +182,7 @@
             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')
--- a/kallithea/controllers/files.py	Wed Oct 25 09:10:30 2017 +0200
+++ b/kallithea/controllers/files.py	Fri Oct 30 22:38:39 2020 +0100
@@ -642,8 +642,7 @@
                                          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')
 
--- a/kallithea/controllers/pullrequests.py	Wed Oct 25 09:10:30 2017 +0200
+++ b/kallithea/controllers/pullrequests.py	Fri Oct 30 22:38:39 2020 +0100
@@ -595,7 +595,7 @@
             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
--- a/kallithea/lib/diffs.py	Wed Oct 25 09:10:30 2017 +0200
+++ b/kallithea/lib/diffs.py	Fri Oct 30 22:38:39 2020 +0100
@@ -66,7 +66,7 @@
 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 @@
                 ###########################################################
                 # 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 @@
     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 @@
             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: