[diffoscope] 02/02: Fix line numbering in HTML diff output

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Dec 18 15:44:59 CET 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository diffoscope.

commit adea97ce7583851509590999bf7c2ff0dc1c74af
Author: Mike Hommey <mh+diffoscope at glandium.org>
Date:   Fri Dec 18 14:30:37 2015 +0000

    Fix line numbering in HTML diff output
    
    Empty lines are passed to output_lines as an empty string and not None.
    
    This bug was present since the HTML presenter based on diff2html.py was
    introduced in debbindiff 12.
    
    Closes: #808199
---
 diffoscope/presenters/html.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index 70763da..8830dc4 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -346,22 +346,20 @@ def output_line(print_func, s1, s2):
 
     print_func(u'<tr class="diff%s">' % type_name)
     try:
-        if s1 is not None:
+        if s1:
             print_func(u'<td class="diffline">%d </td>' % line1)
             print_func(u'<td class="diffpresent">')
             print_func(convert(s1, ponct=1, tag='del'))
             print_func(u'</td>')
         else:
-            s1 = ""
             print_func(u'<td colspan="2">\xa0</td>')
 
-        if s2 is not None:
+        if s2:
             print_func(u'<td class="diffline">%d </td>' % line2)
             print_func(u'<td class="diffpresent">')
             print_func(convert(s2, ponct=1, tag='ins'))
             print_func(u'</td>')
         else:
-            s2 = ""
             print_func(u'<td colspan="2">\xa0</td>')
     finally:
         print_func(u"</tr>\n", force=True)
@@ -369,12 +367,12 @@ def output_line(print_func, s1, s2):
     m = orig1 and re.match(r"^\[ (\d+) lines removed \]$", orig1)
     if m:
         line1 += int(m.group(1))
-    elif orig1 is not None:
+    elif orig1:
         line1 += 1
     m = orig2 and re.match(r"^\[ (\d+) lines removed \]$", orig2)
     if m:
         line2 += int(m.group(1))
-    elif orig2 is not None:
+    elif orig2:
         line2 += 1
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list