Blame SOURCES/0003-Accept-double-eq-as-an-operator-in-reldeps-RhBug-1847946.patch

288843
From 227cf617dd6afd7583f1c864c66ba2ca95e3d09d Mon Sep 17 00:00:00 2001
288843
From: Pavla Kratochvilova <pkratoch@redhat.com>
288843
Date: Wed, 24 Jun 2020 08:48:49 +0200
288843
Subject: [PATCH 1/2] Accept '==' as an operator in reldeps (RhBug:1847946)
288843
288843
Although rpm doesn't support this and using '==' can result in an
288843
unexpected behavior, libdnf accepted '==' by mistake for some time and
288843
other tools (namely Ansible Tower) already rely on it.
288843
288843
This brings back the '==' support with a deprecation warning.
288843
288843
https://bugzilla.redhat.com/show_bug.cgi?id=1847946
288843
---
288843
 libdnf/repo/DependencySplitter.cpp | 14 +++++++++++++-
288843
 1 file changed, 13 insertions(+), 1 deletion(-)
288843
288843
diff --git a/libdnf/repo/DependencySplitter.cpp b/libdnf/repo/DependencySplitter.cpp
288843
index 0030ea6d3..402962286 100644
288843
--- a/libdnf/repo/DependencySplitter.cpp
288843
+++ b/libdnf/repo/DependencySplitter.cpp
288843
@@ -20,16 +20,21 @@
288843
 
288843
 #include "DependencySplitter.hpp"
288843
 #include "../dnf-sack.h"
288843
+#include "../log.hpp"
288843
 #include "../utils/regex/regex.hpp"
288843
 
288843
+#include "bgettext/bgettext-lib.h"
288843
+#include "tinyformat/tinyformat.hpp"
288843
+
288843
 namespace libdnf {
288843
 
288843
 static const Regex RELDEP_REGEX = 
288843
-    Regex("^(\\S*)\\s*(<=|>=|<|>|=)?\\s*(\\S*)$", REG_EXTENDED);
288843
+    Regex("^(\\S*)\\s*(<=|>=|<|>|=|==)?\\s*(\\S*)$", REG_EXTENDED);
288843
 
288843
 static bool
288843
 getCmpFlags(int *cmp_type, std::string matchCmpType)
288843
 {
288843
+    auto logger(Log::getLogger());
288843
     int subexpr_len = matchCmpType.size();
288843
     auto match_start = matchCmpType.c_str();
288843
     if (subexpr_len == 2) {
288843
@@ -41,6 +46,13 @@ getCmpFlags(int *cmp_type, std::string matchCmpType)
288843
             *cmp_type |= HY_GT;
288843
             *cmp_type |= HY_EQ;
288843
         }
288843
+        else if (strncmp(match_start, "==", 2) == 0) {
288843
+            auto msg = tfm::format(_("Using '==' operator in reldeps can result in an undefined "
288843
+                                     "behavior. It is deprecated and the support will be dropped "
288843
+                                     "in future versions. Use '=' operator instead."));
288843
+            logger->warning(msg);
288843
+            *cmp_type |= HY_EQ;
288843
+        }
288843
         else
288843
             return false;
288843
     } else if (subexpr_len == 1) {
288843
288843
From 1f9b14f1d30113a602e18f60ef7ba1f11aead10f Mon Sep 17 00:00:00 2001
288843
From: Pavla Kratochvilova <pkratoch@redhat.com>
288843
Date: Wed, 24 Jun 2020 13:08:48 +0200
288843
Subject: [PATCH 2/2] Add tests for '==' operator in reldeps
288843
288843
---
288843
 python/hawkey/tests/tests/test_reldep.py | 5 +++++
288843
 1 file changed, 5 insertions(+)
288843
288843
diff --git a/python/hawkey/tests/tests/test_reldep.py b/python/hawkey/tests/tests/test_reldep.py
288843
index 8b479cfd7..a9f6cae6f 100644
288843
--- a/python/hawkey/tests/tests/test_reldep.py
288843
+++ b/python/hawkey/tests/tests/test_reldep.py
288843
@@ -61,6 +61,11 @@ def test_custom_querying(self):
288843
         reldep = hawkey.Reldep(self.sack, "P-lib = 3-3")
288843
         q = hawkey.Query(self.sack).filter(provides=reldep)
288843
         self.assertLength(q, 1)
288843
+        # '==' operator is deprecated and the support will be dropped in future
288843
+        # versions (see bug 1847946)
288843
+        reldep = hawkey.Reldep(self.sack, "P-lib == 3-3")
288843
+        q = hawkey.Query(self.sack).filter(provides=reldep)
288843
+        self.assertLength(q, 1)
288843
         reldep = hawkey.Reldep(self.sack, "P-lib >= 3")
288843
         q = hawkey.Query(self.sack).filter(provides=reldep)
288843
         self.assertLength(q, 1)