Changeset - 32757d5e9d0b
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 6 years ago 2020-06-12 00:36:04
mads@kiilerich.com
Grafted from: 5f05b4d7dbd5
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.
2 files changed with 8 insertions and 11 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/diffs.py
Show inline comments
 
@@ -107,12 +107,9 @@ def as_html(table_class='code-difftable'
 
                    '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 @@ def _parse_lines(diff_lines):
 
                # 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 @@ def _parse_lines(diff_lines):
 
                    # 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,
 
                    })
kallithea/tests/models/test_diff_parsers.py
Show inline comments
 
@@ -295,7 +295,7 @@ class TestDiffLib(base.TestController):
 
            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'
0 comments (0 inline, 0 general)