[Reproducible-commits] [diffoscope] 02/02: Fix device handling

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Aug 21 08:32:11 UTC 2015


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

lunar pushed a commit to branch master
in repository diffoscope.

commit 0d5d20a21149803d17158c19b748a0bf950d11a8
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Fri Aug 21 08:29:50 2015 +0000

    Fix device handling
    
    This code was actually never tested before.
    
    Closes: #796288
---
 diffoscope/comparators/device.py | 8 +++++---
 diffoscope/comparators/utils.py  | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/diffoscope/comparators/device.py b/diffoscope/comparators/device.py
index f33af16..e95a02b 100644
--- a/diffoscope/comparators/device.py
+++ b/diffoscope/comparators/device.py
@@ -32,9 +32,12 @@ class Device(File):
         return file.is_device()
 
     def get_device(self):
-        assert self is FilesystemFile
+        assert isinstance(self, FilesystemFile)
         st = os.lstat(self.name)
-        return st.st_mode, os.major(st.st_dev), os.minor(st.st_dev)
+        return st.st_mode, os.major(st.st_rdev), os.minor(st.st_rdev)
+
+    def has_same_content_as(self, other):
+        return self.get_device() == other.get_device()
 
     @contextmanager
     def get_content(self):
@@ -47,7 +50,6 @@ class Device(File):
 
     @needs_content
     def compare(self, other, source=None):
-        logger.debug('my_content %s', self.path)
         with open(self.path) as my_content, \
              open(other.path) as other_content:
             return Difference.from_file(my_content, other_content, self.name, other.name, source=source, comment="device")
diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 5f27ea4..a87ea58 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -130,7 +130,7 @@ def format_device(mode, major, minor):
         kind = 'block'
     else:
         kind = 'weird'
-    return 'device:%s\nmajor: %d\n minor: %d\n' % (kind, major, minor)
+    return 'device:%s\nmajor: %d\nminor: %d\n' % (kind, major, minor)
 
 
 def get_compressed_content_name(path, expected_extension):

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



More information about the Reproducible-commits mailing list