# HG changeset patch # User Thomas De Schampheleire # Date 2020-10-30 22:38:39 # Node ID 410934dd09f4c8e01a8efd916e1a5533bdc3bde8 # Parent 77f13ea8ad3b47b4cf94032a90e07860b44ddcb5 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. diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -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 diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -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') diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py --- a/kallithea/controllers/files.py +++ b/kallithea/controllers/files.py @@ -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') diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -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 diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -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''' % { + _html.append('''\t''' % { 'cc': code_class, - 'inc': comments }) _html.append('''\n\t\t
 
%(code)s
\n''' % { 'code': change['line'] @@ -163,16 +161,15 @@ def wrap_to_table(html): DiffProcessor returns.""" return '''\ - + - +
%s
%s
''' % 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: