changeset 8566:32757d5e9d0b

diff: drop internal inconsistent use of '...' as context line numbers as_html() did in some cases not check for '...' and would thus emit unnecessary html.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 12 Jun 2020 00:36:04 +0200
parents 81fae6754a5a
children cc909683116c
files kallithea/lib/diffs.py kallithea/tests/models/test_diff_parsers.py
diffstat 2 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/diffs.py	Thu Jun 11 22:16:45 2020 +0200
+++ b/kallithea/lib/diffs.py	Fri Jun 12 00:36:04 2020 +0200
@@ -107,12 +107,9 @@
                     'filename': _safe_id(file_info['filename']),
                     'newline_no': change['new_lineno']
                 }
-                cond_old = (change['old_lineno'] != '...' and
-                            change['old_lineno'])
-                cond_new = (change['new_lineno'] != '...' and
-                            change['new_lineno'])
-                no_lineno = (change['old_lineno'] == '...' and
-                             change['new_lineno'] == '...')
+                cond_old = change['old_lineno']
+                cond_new = change['new_lineno']
+                no_lineno = not change['old_lineno'] and not change['new_lineno']
                 if cond_old:
                     anchor_old_id = 'id="%s"' % anchor_old
                 if cond_new:
@@ -587,8 +584,8 @@
                 # skip context only if it's first line
                 if int(gr[0]) > 1:
                     lines.append({
-                        'old_lineno': '...',
-                        'new_lineno': '...',
+                        'old_lineno': '',
+                        'new_lineno': '',
                         'action':     'context',
                         'line':       line,
                     })
@@ -632,8 +629,8 @@
                     # we need to append to lines, since this is not
                     # counted in the line specs of diff
                     lines.append({
-                        'old_lineno':   '...',
-                        'new_lineno':   '...',
+                        'old_lineno':   '',
+                        'new_lineno':   '',
                         'action':       'context',
                         'line':         line,
                     })
--- a/kallithea/tests/models/test_diff_parsers.py	Thu Jun 11 22:16:45 2020 +0200
+++ b/kallithea/tests/models/test_diff_parsers.py	Fri Jun 12 00:36:04 2020 +0200
@@ -295,7 +295,7 @@
             l.append('%(action)-7s %(new_lineno)3s %(old_lineno)3s %(line)r\n' % d)
         s = ''.join(l)
         assert s == r'''
-context ... ... '@@ -51,6 +51,13 @@\n'
+context         '@@ -51,6 +51,13 @@\n'
 unmod    51  51 '<u>\t</u>begin();\n'
 unmod    52  52 '<u>\t</u>\n'
 add      53     '<u>\t</u>int foo;<u class="cr"></u>\n'