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

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