[Reproducible-commits] [debbindiff] 06/07: Rework .changes comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Sat Jun 27 08:59:11 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit abc87a917c6da33e756542bfe3e26ab804fb35ee
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sat Jun 27 08:56:25 2015 +0000

    Rework .changes comparator
    
    This has been the first comparator even written. Let's make it work
    more like the others.
---
 debbindiff/comparators/debian.py | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/debbindiff/comparators/debian.py b/debbindiff/comparators/debian.py
index c3a2a95..9975267 100644
--- a/debbindiff/comparators/debian.py
+++ b/debbindiff/comparators/debian.py
@@ -21,6 +21,7 @@ import sys
 from debbindiff import logger
 from debbindiff.changes import Changes
 import debbindiff.comparators
+from debbindiff.comparators.utils import binary_fallback, returns_details
 from debbindiff.difference import Difference, get_source
 
 
@@ -32,6 +33,8 @@ DOT_CHANGES_FIELDS = [
     ]
 
 
+ at binary_fallback
+ at returns_details
 def compare_dot_changes_files(path1, path2, source=None):
     try:
         dot_changes1 = Changes(filename=path1)
@@ -44,36 +47,25 @@ def compare_dot_changes_files(path1, path2, source=None):
 
     differences = []
     for field in DOT_CHANGES_FIELDS:
-        if dot_changes1[field] != dot_changes2[field]:
-            content1 = "%s: %s" % (field, dot_changes1[field])
-            content2 = "%s: %s" % (field, dot_changes2[field])
-            difference = Difference.from_unicode(
-                             content1, content2,
-                             dot_changes1.get_changes_file(),
-                             dot_changes2.get_changes_file(),
-                             source=source)
-            if difference:
-                differences.append(difference)
-
-    # This will handle differences in the list of files, checksums, priority
-    # and section
-    files1 = dot_changes1.get('Files')
-    files2 = dot_changes2.get('Files')
-    logger.debug(dot_changes1.get_as_string('Files'))
+        differences.append(Difference.from_unicode(
+                               dot_changes1[field].lstrip(),
+                               dot_changes2[field].lstrip(),
+                               path1, path2, source=field))
 
     files_difference = Difference.from_unicode(
         dot_changes1.get_as_string('Files'),
         dot_changes2.get_as_string('Files'),
-        dot_changes1.get_changes_file(),
-        dot_changes2.get_changes_file(),
-        source=source,
-        comment="List of files does not match")
+        path1, path2,
+        source='Files')
 
     if not files_difference:
         return differences
 
-    files1 = dict([(d['name'], d) for d in files1])
-    files2 = dict([(d['name'], d) for d in files2])
+    differences.append(files_difference)
+
+    # we are only interested in file names
+    files1 = dict([(d['name'], d) for d in dot_changes1.get('Files')])
+    files2 = dict([(d['name'], d) for d in dot_changes2.get('Files')])
 
     for filename in sorted(set(files1.keys()).intersection(files2.keys())):
         d1 = files1[filename]
@@ -81,12 +73,11 @@ def compare_dot_changes_files(path1, path2, source=None):
         if d1['md5sum'] != d2['md5sum']:
             logger.debug("%s mentioned in .changes have "
                          "differences", filename)
-            files_difference.add_details(
+            differences.append(
                 debbindiff.comparators.compare_files(
                     dot_changes1.get_path(filename),
                     dot_changes2.get_path(filename),
                     source=get_source(dot_changes1.get_path(filename),
                                       dot_changes2.get_path(filename))))
 
-    differences.append(files_difference)
     return differences

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



More information about the Reproducible-commits mailing list