Blame SOURCES/0001-Revert-selector-prefer-obsoletes-Related-RhBug-10965.patch

6494a1
From 1a32ea40288d88be40030665090bb2ae418cd0aa Mon Sep 17 00:00:00 2001
6494a1
From: Colin Walters <walters@verbum.org>
6494a1
Date: Tue, 25 Oct 2016 09:53:14 -0400
6494a1
Subject: [PATCH] Revert "selector: prefer obsoletes (Related:RhBug:1096506)"
6494a1
6494a1
This reverts commit 94ac2e5b980f9095faa372568a8e381e8a4523bc.
6494a1
---
6494a1
 data/tests/hawkey/greedy.repo |  2 --
6494a1
 libdnf/hy-goal.c              | 34 ++--------------------------------
6494a1
 tests/hawkey/test_goal.c      | 23 -----------------------
6494a1
 3 files changed, 2 insertions(+), 57 deletions(-)
6494a1
6494a1
diff --git a/data/tests/hawkey/greedy.repo b/data/tests/hawkey/greedy.repo
6494a1
index d450885..64bb85a 100644
6494a1
--- a/libdnf/data/tests/hawkey/greedy.repo
6494a1
+++ b/libdnf/data/tests/hawkey/greedy.repo
6494a1
@@ -5,7 +5,5 @@
6494a1
 =Pkg: B 1 0 noarch
6494a1
 =Rec: C
6494a1
 =Prv: somereq
6494a1
-=Obs: somereq
6494a1
 =Pkg: C 1 0 noarch
6494a1
 =Prv: somereq
6494a1
-=Pkg: somereq 1 0 noarch
6494a1
diff --git a/libdnf/hy-goal.c b/libdnf/hy-goal.c
6494a1
index b404921..c50e8f5 100644
6494a1
--- a/libdnf/libdnf/hy-goal.c
6494a1
+++ b/libdnf/libdnf/hy-goal.c
6494a1
@@ -523,36 +523,6 @@ filter_name2job(DnfSack *sack, const struct _Filter *f, Queue *job)
6494a1
     return 0;
6494a1
 }
6494a1
 
6494a1
-/**
6494a1
- * add_preferred_provide:
6494a1
- * when searching by provides the packages that contain the same
6494a1
- * name as provide or contain obsoletes with the same name as their
6494a1
- * provide will be picked first
6494a1
- */
6494a1
-static void
6494a1
-add_preferred_provide(DnfSack *sack, Queue *job, Id id)
6494a1
-{
6494a1
-    g_autoptr(GPtrArray) plist = g_ptr_array_new_with_free_func(
6494a1
-        (GDestroyNotify) g_object_unref);
6494a1
-    Pool *pool = dnf_sack_get_pool(sack);
6494a1
-    const char *name = pool_dep2str(pool, id);
6494a1
-    HyQuery q = hy_query_create(sack);
6494a1
-    hy_query_filter(q, HY_PKG_NAME, HY_NEQ, name);
6494a1
-    DnfPackageSet *pset = hy_query_run_set(q);
6494a1
-    hy_query_filter(q, HY_PKG_PROVIDES, HY_EQ, name);
6494a1
-    hy_query_filter_package_in(q, HY_PKG_OBSOLETES, HY_NEQ, pset);
6494a1
-    DnfPackage *pkg;
6494a1
-    plist = hy_query_run(q);
6494a1
-    for (guint i = 0; i < plist->len; i++) {
6494a1
-        pkg = g_ptr_array_index(plist, i);
6494a1
-        queue_push2(job, SOLVER_DISFAVOR|SOLVER_SOLVABLE,
6494a1
-                    dnf_package_get_id(pkg));
6494a1
-    }
6494a1
-    queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
6494a1
-    hy_query_free(q);
6494a1
-    g_object_unref(pset);
6494a1
-}
6494a1
-
6494a1
 static int
6494a1
 filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
6494a1
 {
6494a1
@@ -568,7 +538,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
6494a1
     switch (f->cmp_type) {
6494a1
     case HY_EQ:
6494a1
         id = dnf_reldep_get_id (f->matches[0].reldep);
6494a1
-        add_preferred_provide(sack, job, id);
6494a1
+        queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
6494a1
         break;
6494a1
     case HY_GLOB:
6494a1
         dataiterator_init(&di, pool, 0, 0, SOLVABLE_PROVIDES, name, SEARCH_GLOB);
6494a1
@@ -579,7 +549,7 @@ filter_provides2job(DnfSack *sack, const struct _Filter *f, Queue *job)
6494a1
         assert(di.idp);
6494a1
         id = *di.idp;
6494a1
         if (!job_has(job, SOLVABLE_PROVIDES, id))
6494a1
-            add_preferred_provide(sack, job, id);
6494a1
+            queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
6494a1
         dataiterator_free(&di);
6494a1
         break;
6494a1
     default:
6494a1
diff --git a/tests/hawkey/test_goal.c b/tests/hawkey/test_goal.c
6494a1
index 6217c38..ce2c8bd 100644
6494a1
--- a/libdnf/tests/hawkey/test_goal.c
6494a1
+++ b/libdnf/tests/hawkey/test_goal.c
6494a1
@@ -230,28 +230,6 @@ START_TEST(test_goal_install_selector)
6494a1
 }
6494a1
 END_TEST
6494a1
 
6494a1
-START_TEST(test_goal_install_selector_obsoletes_first)
6494a1
-{
6494a1
-    HySelector sltr;
6494a1
-    HyGoal goal = hy_goal_create(test_globals.sack);
6494a1
-
6494a1
-    sltr = hy_selector_create(test_globals.sack);
6494a1
-    hy_selector_set(sltr, HY_PKG_PROVIDES, HY_EQ, "somereq");
6494a1
-    fail_if(!hy_goal_install_selector(goal, sltr, NULL));
6494a1
-    hy_selector_free(sltr);
6494a1
-
6494a1
-    fail_if(hy_goal_run(goal));
6494a1
-    assert_iueo(goal, 1, 0, 0, 0);
6494a1
-
6494a1
-    GPtrArray *plist = hy_goal_list_installs(goal, NULL);
6494a1
-    char *nvra = dnf_package_get_nevra(g_ptr_array_index(plist, 0));
6494a1
-    ck_assert_str_eq(nvra, "B-1-0.noarch");
6494a1
-    g_free(nvra);
6494a1
-    g_ptr_array_unref(plist);
6494a1
-    hy_goal_free(goal);
6494a1
-}
6494a1
-END_TEST
6494a1
-
6494a1
 START_TEST(test_goal_install_selector_err)
6494a1
 {
6494a1
     int rc;
6494a1
@@ -1459,7 +1437,6 @@ goal_suite(void)
6494a1
     tc = tcase_create("Greedy");
6494a1
     tcase_add_unchecked_fixture(tc, fixture_greedy_only, teardown);
6494a1
     tcase_add_test(tc, test_goal_run_all);
6494a1
-    tcase_add_test(tc, test_goal_install_selector_obsoletes_first);
6494a1
     tcase_add_test(tc, test_goal_install_weak_deps);
6494a1
     suite_add_tcase(s, tc);
6494a1
 
6494a1
-- 
6494a1
2.7.4
6494a1