richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0003-Accept-multiple-specs-in-repoquery-options-RhBug16678981656801.patch

1f580a
From 524950fb6c647194ad9e0d3b7b2195d671424d1c Mon Sep 17 00:00:00 2001
1f580a
From: Jaroslav Mracek <jmracek@redhat.com>
1f580a
Date: Tue, 9 Apr 2019 20:54:12 +0200
1f580a
Subject: [PATCH] Accept multiple specs in repoquery options (RhBug:1667898,1656801)
1f580a
1f580a
It allows with repoquery command to use --what* options multiple times
1f580a
(append option) or add multiple arguments separated by comma.
1f580a
1f580a
https://bugzilla.redhat.com/show_bug.cgi?id=1667898
1f580a
https://bugzilla.redhat.com/show_bug.cgi?id=1656801
1f580a
---
1f580a
 dnf.spec                      |  2 +-
1f580a
 dnf/cli/commands/repoquery.py | 39 +++++++++++++++++++++++++--------------
1f580a
 tests/test_repoquery.py       |  4 ++--
1f580a
 3 files changed, 28 insertions(+), 17 deletions(-)
1f580a
1f580a
diff --git a/dnf.spec b/dnf.spec
1f580a
index bbbe954..e3002db 100644
1f580a
--- a/dnf.spec
1f580a
+++ b/dnf.spec
1f580a
@@ -1,5 +1,5 @@
1f580a
 # default dependencies
1f580a
-%global hawkey_version 0.35.1
1f580a
+%global hawkey_version 0.35.2
1f580a
 %global libcomps_version 0.1.8
1f580a
 %global libmodulemd_version 1.4.0
1f580a
 %global rpm_version 4.14.0
1f580a
diff --git a/dnf/cli/commands/repoquery.py b/dnf/cli/commands/repoquery.py
1f580a
index 0e5073f..c31501f 100644
1f580a
--- a/dnf/cli/commands/repoquery.py
1f580a
+++ b/dnf/cli/commands/repoquery.py
1f580a
@@ -126,24 +126,33 @@ class RepoQueryCommand(commands.Command):
1f580a
                             help=_('show only results from this ARCH'))
1f580a
         parser.add_argument('-f', '--file', metavar='FILE', nargs='+',
1f580a
                             help=_('show only results that owns FILE'))
1f580a
-        parser.add_argument('--whatconflicts', metavar='REQ',
1f580a
+        parser.add_argument('--whatconflicts', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that conflict REQ'))
1f580a
-        parser.add_argument('--whatdepends', metavar='REQ',
1f580a
+        parser.add_argument('--whatdepends', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('shows results that requires, suggests, supplements, enhances,'
1f580a
                                    'or recommends package provides and files REQ'))
1f580a
-        parser.add_argument('--whatobsoletes', metavar='REQ',
1f580a
+        parser.add_argument('--whatobsoletes', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that obsolete REQ'))
1f580a
-        parser.add_argument('--whatprovides', metavar='REQ',
1f580a
+        parser.add_argument('--whatprovides', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that provide REQ'))
1f580a
-        parser.add_argument('--whatrequires', metavar='REQ',
1f580a
+        parser.add_argument('--whatrequires', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('shows results that requires package provides and files REQ'))
1f580a
-        parser.add_argument('--whatrecommends', metavar='REQ',
1f580a
+        parser.add_argument('--whatrecommends', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that recommend REQ'))
1f580a
-        parser.add_argument('--whatenhances', metavar='REQ',
1f580a
+        parser.add_argument('--whatenhances', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that enhance REQ'))
1f580a
-        parser.add_argument('--whatsuggests', metavar='REQ',
1f580a
+        parser.add_argument('--whatsuggests', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that suggest REQ'))
1f580a
-        parser.add_argument('--whatsupplements', metavar='REQ',
1f580a
+        parser.add_argument('--whatsupplements', default=[], action=OptionParser._SplitCallback,
1f580a
+                            metavar='REQ',
1f580a
                             help=_('show only results that supplement REQ'))
1f580a
         whatrequiresform = parser.add_mutually_exclusive_group()
1f580a
         whatrequiresform.add_argument("--alldeps", action="store_true",
1f580a
@@ -354,10 +363,12 @@ class RepoQueryCommand(commands.Command):
1f580a
         return t.union(done)
1f580a
 
1f580a
     def by_all_deps(self, requires_name, depends_name, query):
1f580a
-        name = requires_name or depends_name
1f580a
-        defaultquery = query.intersection(dnf.subject.Subject(name).get_best_query(
1f580a
-            self.base.sack, with_provides=False, with_filenames=False))
1f580a
-        requiresquery = query.filter(requires__glob=name)
1f580a
+        names = requires_name or depends_name
1f580a
+        defaultquery = self.base.sack.query().filter(empty=True)
1f580a
+        for name in names:
1f580a
+            defaultquery.union(query.intersection(dnf.subject.Subject(name).get_best_query(
1f580a
+                self.base.sack, with_provides=False, with_filenames=False)))
1f580a
+        requiresquery = query.filter(requires__glob=names)
1f580a
         if depends_name:
1f580a
             requiresquery = requiresquery.union(query.filter(recommends__glob=depends_name))
1f580a
             requiresquery = requiresquery.union(query.filter(enhances__glob=depends_name))
1f580a
@@ -446,7 +457,7 @@ class RepoQueryCommand(commands.Command):
1f580a
         if self.opts.whatobsoletes:
1f580a
             q.filterm(obsoletes=self.opts.whatobsoletes)
1f580a
         if self.opts.whatprovides:
1f580a
-            query_for_provide = q.filter(provides__glob=[self.opts.whatprovides])
1f580a
+            query_for_provide = q.filter(provides__glob=self.opts.whatprovides)
1f580a
             if query_for_provide:
1f580a
                 q = query_for_provide
1f580a
             else:
1f580a
diff --git a/tests/test_repoquery.py b/tests/test_repoquery.py
1f580a
index 9e6cc7d..9182537 100644
1f580a
--- a/tests/test_repoquery.py
1f580a
+++ b/tests/test_repoquery.py
1f580a
@@ -78,8 +78,8 @@ class ArgParseTest(tests.support.TestCase):
1f580a
 
1f580a
     def test_parse(self):
1f580a
         tests.support.command_configure(self.cmd, ['--whatrequires', 'prudence'])
1f580a
-        self.assertIsNone(self.cmd.opts.whatprovides)
1f580a
-        self.assertEqual(self.cmd.opts.whatrequires, 'prudence')
1f580a
+        self.assertEqual(self.cmd.opts.whatprovides, [])
1f580a
+        self.assertEqual(self.cmd.opts.whatrequires, ['prudence'])
1f580a
         self.assertEqual(self.cmd.opts.queryformat,
1f580a
                          dnf.cli.commands.repoquery.QFORMAT_DEFAULT)
1f580a
 
1f580a
--
1f580a
libgit2 0.28.2
1f580a