[Reproducible-commits] [diffoscope] 09/23: XXX tar listing command
Jérémy Bobbio
lunar at moszumanska.debian.org
Sat Sep 19 23:18:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch pu/py3
in repository diffoscope.
commit f9f5ce0b0c84a5204173b829c9cb5fb13587467b
Author: Jérémy Bobbio <lunar at debian.org>
Date: Sat Sep 19 18:24:01 2015 +0200
XXX tar listing command
---
diffoscope/comparators/deb.py | 8 ++------
diffoscope/comparators/tar.py | 22 +++++++---------------
tests/comparators/test_utils.py | 2 +-
tests/data/tar_listing_expected_diff | 16 ++++++++--------
4 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/diffoscope/comparators/deb.py b/diffoscope/comparators/deb.py
index 157aafb..a26f654 100644
--- a/diffoscope/comparators/deb.py
+++ b/diffoscope/comparators/deb.py
@@ -27,7 +27,7 @@ from diffoscope.difference import Difference
from diffoscope.comparators.binary import File, needs_content
from diffoscope.comparators.utils import \
Archive, ArchiveMember, get_ar_content
-from diffoscope.comparators.tar import TarContainer, get_tar_listing
+from diffoscope.comparators.tar import TarContainer, TarListing
AR_EXTRACTION_BUFFER_SIZE = 32768
@@ -153,10 +153,6 @@ class DebDataTarFile(File):
ignore_files = self.container.source.container.source.files_with_same_content_in_data
with DebTarContainer(self, ignore_files).open() as my_container, \
DebTarContainer(other, ignore_files).open() as other_container:
- # look up differences in file list and file metadata
- my_listing = get_tar_listing(my_container.archive)
- other_listing = get_tar_listing(other_container.archive)
- differences.append(Difference.from_unicode(
- my_listing, other_listing, self.name, other.name, source="metadata"))
+ differences.append(Difference.from_command(TarListing, self.path, other.path))
differences.extend(my_container.compare(other_container))
return differences
diff --git a/diffoscope/comparators/tar.py b/diffoscope/comparators/tar.py
index 19b025f..59063f1 100644
--- a/diffoscope/comparators/tar.py
+++ b/diffoscope/comparators/tar.py
@@ -30,7 +30,7 @@ from diffoscope.comparators.binary import File, needs_content
from diffoscope.comparators.device import Device
from diffoscope.comparators.directory import Directory
from diffoscope.comparators.symlink import Symlink
-from diffoscope.comparators.utils import Archive, ArchiveMember
+from diffoscope.comparators.utils import Archive, ArchiveMember, Command, tool_required
class TarMember(ArchiveMember):
def is_directory(self):
@@ -125,15 +125,11 @@ class TarContainer(Archive):
return TarMember(self, member_name)
-def get_tar_listing(tar):
- orig_stdout = sys.stdout
- output = BytesIO()
- try:
- sys.stdout = output
- tar.list(verbose=True)
- return output.getvalue().decode('utf-8')
- finally:
- sys.stdout = orig_stdout
+class TarListing(Command):
+ @tool_required('tar')
+ def cmdline(self):
+ return ['tar', '--numeric-owner', '--full-time', '-tvf', self.path]
+
class TarFile(File):
RE_FILE_TYPE = re.compile(r'\btar archive\b')
@@ -147,10 +143,6 @@ class TarFile(File):
differences = []
with TarContainer(self).open() as my_container, \
TarContainer(other).open() as other_container:
- # look up differences in file list and file metadata
- my_listing = get_tar_listing(my_container.archive)
- other_listing = get_tar_listing(other_container.archive)
- differences.append(Difference.from_unicode(
- my_listing, other_listing, self.name, other.name, source="metadata"))
+ differences.append(Difference.from_command(TarListing, self.path, other.path))
differences.extend(my_container.compare(other_container))
return differences
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index 6dda4e0..cc1676e 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -62,7 +62,7 @@ def test_no_fuzzy_matching(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2):
monkeypatch.setattr(Config, 'fuzzy_threshold', 0)
difference = fuzzy_tar_in_tar1.compare(fuzzy_tar_in_tar2)
assert len(difference.details) == 1
- assert difference.details[0].source1 == 'metadata'
+ assert difference.details[0].source1 == 'tar --numeric-owner --full-time -tvf {}'
def test_no_fuzzy_matching_new_file(monkeypatch, fuzzy_tar_in_tar1, fuzzy_tar_in_tar2):
monkeypatch.setattr(Config, 'fuzzy_threshold', 0)
diff --git a/tests/data/tar_listing_expected_diff b/tests/data/tar_listing_expected_diff
index 505d11a..b3eab4e 100644
--- a/tests/data/tar_listing_expected_diff
+++ b/tests/data/tar_listing_expected_diff
@@ -1,9 +1,9 @@
@@ -1,4 +1,4 @@
---rwxr-xr-x lunar/lunar 0 2015-06-29 15:49:09 dir/
---rw-r--r-- lunar/lunar 446 2015-06-29 15:49:09 dir/text
---rw-r--r-- root/root 1,3 2015-06-29 15:49:09 dir/null
---rwxrwxrwx lunar/lunar 0 2015-06-29 15:49:09 dir/link -> broken
-+-rwxr-xr-x lunar/lunar 0 2015-06-29 15:49:41 dir/
-+-rw-r--r-- lunar/lunar 671 2015-06-29 15:49:41 dir/text
-+-rw-r--r-- root/root 1,3 2015-06-29 15:49:41 dir/null
-+-rwxrwxrwx lunar/lunar 0 2015-06-29 15:49:41 dir/link -> really-broken
+-drwxr-xr-x 1000/1000 0 2015-06-29 15:49:09 dir/
+--rw-r--r-- 1000/1000 446 2015-06-29 15:49:09 dir/text
+-crw-r--r-- 0/0 1,3 2015-06-29 15:49:09 dir/null
+-lrwxrwxrwx 1000/1000 0 2015-06-29 15:49:09 dir/link -> broken
++drwxr-xr-x 1000/1000 0 2015-06-29 15:49:41 dir/
++-rw-r--r-- 1000/1000 671 2015-06-29 15:49:41 dir/text
++crw-r--r-- 0/0 1,3 2015-06-29 15:49:41 dir/null
++lrwxrwxrwx 1000/1000 0 2015-06-29 15:49:41 dir/link -> really-broken
--
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