[gentoo-commits] proj/portage:master commit in: lib/portage/dep/, lib/portage/tests/resolver/

2022-03-05 Thread Zac Medico
commit: 17d64dba6363c15069f49bfe3dc2060a9811e288
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Mar  5 19:22:08 2022 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sat Mar  5 19:23:39 2022 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=17d64dba

Revert "dep_zapdeps: avoid new slots when appropriate (bug 828136)"

Revert the change from bug 828136, since it prevents solving
of some blockers unless --update and --deep are specified as
reported in bug 833014.

Bug: https://bugs.gentoo.org/833014
Reverts: a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/dep/dep_check.py |  6 +-
 lib/portage/tests/resolver/test_installkernel.py | 20 +---
 .../tests/resolver/test_unecessary_slot_upgrade.py   | 11 ---
 3 files changed, 2 insertions(+), 35 deletions(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 8ca4c0b9d..9fccda08b 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -376,7 +376,6 @@ def dep_zapdeps(
 # c) contains masked installed packages
 # d) is the first item
 
-no_new_slots = []
 preferred_in_graph = []
 preferred_installed = preferred_in_graph
 preferred_any_slot = preferred_in_graph
@@ -392,7 +391,6 @@ def dep_zapdeps(
 # unsat_use_* must come after preferred_non_installed
 # for correct ordering in cases like || ( foo[a] foo[b] ).
 choice_bins = (
-no_new_slots,
 preferred_in_graph,
 preferred_non_installed,
 unsat_use_in_graph,
@@ -691,9 +689,7 @@ def dep_zapdeps(
 other.append(this_choice)
 else:
 if all_use_satisfied:
-if new_slot_count == 0 and not want_update:
-no_new_slots.append(this_choice)
-elif all_in_graph:
+if all_in_graph:
 preferred_in_graph.append(this_choice)
 elif all_installed:
 if all_installed_slots:

diff --git a/lib/portage/tests/resolver/test_installkernel.py 
b/lib/portage/tests/resolver/test_installkernel.py
index b73bbe5bb..5909b53aa 100644
--- a/lib/portage/tests/resolver/test_installkernel.py
+++ b/lib/portage/tests/resolver/test_installkernel.py
@@ -58,25 +58,8 @@ class InstallKernelTestCase(TestCase):
 ),
 ],
 ),
-# Demonstrate bug 833014, where the calculation fails unless
+# Test bug 833014, where the calculation failed unless
 # --update and --deep are specified.
-ResolverPlaygroundTestCase(
-[
-"sys-kernel/installkernel-systemd-boot",
-"sys-kernel/gentoo-kernel-bin",
-],
-ambiguous_merge_order=True,
-success=False,
-mergelist=[
-"sys-kernel/installkernel-systemd-boot-1",
-"sys-kernel/gentoo-kernel-bin-5.15.23",
-"virtual/dist-kernel-5.15.23",
-(
-"!sys-kernel/installkernel-gentoo",
-"!sys-kernel/installkernel-systemd-boot",
-),
-],
-),
 ResolverPlaygroundTestCase(
 [
 "sys-kernel/installkernel-systemd-boot",
@@ -84,7 +67,6 @@ class InstallKernelTestCase(TestCase):
 ],
 ambiguous_merge_order=True,
 success=True,
-options={"--deep": True, "--update": True},
 mergelist=[
 "virtual/dist-kernel-5.15.23",
 "sys-kernel/installkernel-systemd-boot-1",

diff --git a/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py 
b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py
index f8b8b346a..a89ebdb67 100644
--- a/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py
+++ b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py
@@ -26,13 +26,6 @@ class UnnecessarySlotrUpgradeTestCase(TestCase):
 test_cases = (
 # Test bug 828136, where an unnecessary python slot upgrade
 # was triggered.
-ResolverPlaygroundTestCase(
-[
-"app-misc/a",
-],
-success=True,
-mergelist=("app-misc/a-1",),
-),
 ResolverPlaygroundTestCase(
 [
 "app-misc/a",
@@ -42,10 +35,6 @@ class UnnecessarySlotrUpgradeTestCase(TestCase):
 "dev-lang/python-3.10",
 "app-misc/a-1",
 ),
-options={
-"--deep": True,
-"--update": True,
-},
 

[gentoo-commits] proj/portage:master commit in: lib/portage/dep/, lib/portage/tests/resolver/

2021-12-06 Thread Zac Medico
commit: a7289ac0eaaa0d435bf6d9bfb2724a6b39adcbee
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Dec  4 23:54:47 2021 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Dec  5 18:40:44 2021 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a7289ac0

dep_zapdeps: avoid new slots when appropriate (bug 828136)

Place choices that do not pull in new slots into a preferred
choice bin, so that they will not be mixed with choices that
contain unnecessary upgrades. This fixes the included test
case so that an unnecessary new python slot is not pulled in.

Bug: https://bugs.gentoo.org/828136
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/dep/dep_check.py   |  6 ++-
 .../tests/resolver/test_unecessary_slot_upgrade.py | 62 ++
 2 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 9fccda08b..8ca4c0b9d 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -376,6 +376,7 @@ def dep_zapdeps(
 # c) contains masked installed packages
 # d) is the first item
 
+no_new_slots = []
 preferred_in_graph = []
 preferred_installed = preferred_in_graph
 preferred_any_slot = preferred_in_graph
@@ -391,6 +392,7 @@ def dep_zapdeps(
 # unsat_use_* must come after preferred_non_installed
 # for correct ordering in cases like || ( foo[a] foo[b] ).
 choice_bins = (
+no_new_slots,
 preferred_in_graph,
 preferred_non_installed,
 unsat_use_in_graph,
@@ -689,7 +691,9 @@ def dep_zapdeps(
 other.append(this_choice)
 else:
 if all_use_satisfied:
-if all_in_graph:
+if new_slot_count == 0 and not want_update:
+no_new_slots.append(this_choice)
+elif all_in_graph:
 preferred_in_graph.append(this_choice)
 elif all_installed:
 if all_installed_slots:

diff --git a/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py 
b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py
new file mode 100644
index 0..f8b8b346a
--- /dev/null
+++ b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py
@@ -0,0 +1,62 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import (
+ResolverPlayground,
+ResolverPlaygroundTestCase,
+)
+
+
+class UnnecessarySlotrUpgradeTestCase(TestCase):
+def testUnnecessarySlotUpgrade(self):
+ebuilds = {
+"app-misc/a-1": {
+"EAPI": "8",
+"RDEPEND": "|| ( dev-lang/python:3.10 dev-lang/python:3.9 ) || 
( dev-lang/python:3.10 dev-lang/python:3.9 )",
+},
+"dev-lang/python-3.9": {"SLOT": "3.9"},
+"dev-lang/python-3.10": {"SLOT": "3.10"},
+}
+
+installed = {
+"dev-lang/python-3.9": {"SLOT": "3.9"},
+}
+
+test_cases = (
+# Test bug 828136, where an unnecessary python slot upgrade
+# was triggered.
+ResolverPlaygroundTestCase(
+[
+"app-misc/a",
+],
+success=True,
+mergelist=("app-misc/a-1",),
+),
+ResolverPlaygroundTestCase(
+[
+"app-misc/a",
+],
+success=True,
+mergelist=(
+"dev-lang/python-3.10",
+"app-misc/a-1",
+),
+options={
+"--deep": True,
+"--update": True,
+},
+),
+)
+
+playground = ResolverPlayground(
+debug=False, ebuilds=ebuilds, installed=installed
+)
+
+try:
+for test_case in test_cases:
+playground.run_TestCase(test_case)
+self.assertEqual(test_case.test_success, True, 
test_case.fail_msg)
+finally:
+playground.debug = False
+playground.cleanup()



[gentoo-commits] proj/portage:master commit in: lib/portage/dep/, lib/portage/tests/resolver/

2020-02-08 Thread Zac Medico
commit: 216c52d1ea447fbf06f6ac00e5d771780508601d
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Feb  8 18:41:56 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sat Feb  8 18:48:45 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=216c52d1

dep_zapdeps: prefer choices with all in graph (bug 649622)

Prefer choices where all packages have been pulled into the
graph (except for choices that eliminate upgrades). This
logic must be consistent between both update and removal
(depclean) actions in order to avoid pulling in packages
only to have them removed by depclean, as reported in
bug 649622 for virtual/w3m.

Bug: https://bugs.gentoo.org/649622
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/dep/dep_check.py  | 8 +++-
 lib/portage/tests/resolver/test_or_choices.py | 9 ++---
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 8adb92da2..1dd289eec 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -722,11 +722,9 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None,
# Prefer upgrades.
(has_upgrade and not has_downgrade)
 
-   # For removal actions, prefer choices 
where all packages
-   # have been pulled into the graph, 
except for choices that
-   # eliminate upgrades.
-   or (graph_interface and 
graph_interface.removal_action and
-   choice_1.all_in_graph and not 
choice_2.all_in_graph and
+   # Prefer choices where all packages 
have been pulled into
+   # the graph, except for choices that 
eliminate upgrades.
+   or (choice_1.all_in_graph and not 
choice_2.all_in_graph and
not (has_downgrade and not has_upgrade))
):
# promote choice_1 in front of choice_2

diff --git a/lib/portage/tests/resolver/test_or_choices.py 
b/lib/portage/tests/resolver/test_or_choices.py
index f1cc75499..5679d0b5b 100644
--- a/lib/portage/tests/resolver/test_or_choices.py
+++ b/lib/portage/tests/resolver/test_or_choices.py
@@ -465,13 +465,13 @@ class OrChoicesTestCase(TestCase):
 
test_cases = (
 
-   # Test for bug 649622, where virtual/w3m is installed 
only
+   # Test for bug 649622, where virtual/w3m was pulled in 
only
# to be removed by the next emerge --depclean.
ResolverPlaygroundTestCase(
['@world'],
options = {'--update': True, '--deep': True},
success = True,
-   mergelist = ['virtual/w3m-0']
+   mergelist = []
),
 
)
@@ -499,7 +499,10 @@ class OrChoicesTestCase(TestCase):
 
# Test for bug 649622, where virtual/w3m is removed by
# emerge --depclean immediately after it's installed
-   # by a world update.
+   # by a world update. Note that removal of virtual/w3m 
here
+   # is essentially indistinguishable from removal of
+   # dev-util/cmake-bootstrap in the depclean test case for
+   # bug 703440.
ResolverPlaygroundTestCase(
[],
options={'--depclean': True},



[gentoo-commits] proj/portage:master commit in: lib/portage/dep/, lib/portage/tests/resolver/

2020-02-01 Thread Zac Medico
commit: d77d933b4a9cb2b830e661806a2a8689ffbac0ef
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Feb  1 04:53:45 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sat Feb  1 20:54:11 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d77d933b

depclean: do not eliminate upgrades (bug 707108)

For depclean actions, prefer choices where all packages have been
pulled into the graph, except for choices that eliminate upgrades.
This solves the test case for bug 707108, where depclean eliminated
a new slot of python that had been pulled in by a world update.
This should also prevent non-deterministic elimination of the
latest vala slot that was reported in bug 693790.

NOTE: There's a common perception (expressed in bug 705700) that
emerge is pulling in an "unecessary" python slot in cases when that
python slot is not enabled in PYTHON_TARGETS. However, the so-called
"unnecessary" slot is practically indistinguishable from a desirable
upgrade such as the missed llvm slot upgrade that was reported in
bug 706278. Therefore, be advised that emerge must pull in the
highest visible slot (regardless of PYTHON_TARGETS) in order to
ensure that a desirable upgrade is not missed.

Fixes: f7d83d75c6b0 ("dep_zapdeps: adjust || preference for slot upgrades (bug 
706278)")
Bug: https://bugs.gentoo.org/707108
Bug: https://bugs.gentoo.org/706278
Bug: https://bugs.gentoo.org/705700
Bug: https://bugs.gentoo.org/693790
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/dep/dep_check.py  | 23 +--
 lib/portage/tests/resolver/test_or_choices.py |  4 ++--
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index a7ae2cfa4..8adb92da2 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -690,17 +690,12 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None,
# choice_1 will not be promoted, so 
move on
break
if (
-   # For removal actions, prefer choices 
where all packages
-   # have been pulled into the graph.
-   (graph_interface and 
graph_interface.removal_action and
-   choice_1.all_in_graph and not 
choice_2.all_in_graph)
-
# Prefer choices where 
all_installed_slots is True, except
# in cases where we want to upgrade to 
a new slot as in
# bug 706278. Don't compare 
new_slot_count here since that
# would aggressively override the 
preference order defined
# in the ebuild, breaking the test case 
for bug 645002.
-   or (choice_1.all_installed_slots and
+   (choice_1.all_installed_slots and
not choice_2.all_installed_slots and
not choice_2.want_update)
):
@@ -711,8 +706,6 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None,
break
 
intersecting_cps = 
cps.intersection(choice_2.cp_map)
-   if not intersecting_cps:
-   continue
has_upgrade = False
has_downgrade = False
for cp in intersecting_cps:
@@ -724,8 +717,18 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None,
has_upgrade = True
else:
has_downgrade = True
-   break
-   if has_upgrade and not has_downgrade:
+
+   if (
+   # Prefer upgrades.
+   (has_upgrade and not has_downgrade)
+
+   # For removal actions, prefer choices 
where all packages
+   # have been pulled into the graph, 
except for choices that
+   # eliminate upgrades.
+   or (graph_interface and 
graph_interface.removal_action and
+   choice_1.all_in_graph and not 
choice_2.all_in_graph and
+   not (has_downgrade and not has_upgrade))
+   ):
 

[gentoo-commits] proj/portage:master commit in: lib/portage/dep/, lib/portage/tests/resolver/

2020-01-22 Thread Zac Medico
commit: ef66aab178180288132177011ad0e910fb2cd55e
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Jan 21 03:19:01 2020 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Jan 23 05:52:43 2020 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ef66aab1

dep_zapdeps: break more buildtime cycles (bug 705986)

Buildtime cycle breaking was not enabled in cases where
the all_in_graph variable was False, and this prevented the
pypy / pypy-exe dependency cycle from being broken as shown
in the test case for bug 705986. In order to break more
buildtime cycles, enable cycle breaking regardless of the
state of the all_in_graph variable.

Bug: https://bugs.gentoo.org/705986
Signed-off-by: Zac Medico  gentoo.org>

 lib/portage/dep/dep_check.py|  5 ++---
 lib/portage/tests/resolver/test_circular_choices.py | 14 --
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index 3a0c7bbe9..321d961dd 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2018 Gentoo Foundation
+# Copyright 2010-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -570,8 +570,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None,
circular_atom = None
if not (parent is None or priority is None) and 
\
(parent.onlydeps or
-   (all_in_graph and priority.buildtime and
-   not (priority.satisfied or 
priority.optional))):
+   (priority.buildtime and not 
priority.satisfied and not priority.optional)):
# Check if the atom would 
result in a direct circular
# dependency and try to avoid 
that if it seems likely
# to be unresolvable. This is 
only relevant for

diff --git a/lib/portage/tests/resolver/test_circular_choices.py 
b/lib/portage/tests/resolver/test_circular_choices.py
index 968677a46..a383519fc 100644
--- a/lib/portage/tests/resolver/test_circular_choices.py
+++ b/lib/portage/tests/resolver/test_circular_choices.py
@@ -1,4 +1,4 @@
-# Copyright 2011-2019 Gentoo Authors
+# Copyright 2011-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -184,17 +184,11 @@ class CircularPypyExeTestCase(TestCase):
}
 
test_cases = (
-   # Demonstrate bug 705986, where a USE change suggestion 
is given
-   # even though an || preference adjustment is available.
+   # Demonstrate bug 705986, where a USE change suggestion 
was given
+   # even though an || preference adjustment would solve 
the problem
+   # by pulling in pypy-exe-bin instead of pypy-exe.
ResolverPlaygroundTestCase(
['dev-python/pypy'],
-   circular_dependency_solutions = 
{'dev-python/pypy-7.3.0': {frozenset({('low-memory', True)})}},
-   success = False,
-   ),
-   # Demonstrate explicit pypy-exe-bin argument used as a 
workaround
-   # for bug 705986.
-   ResolverPlaygroundTestCase(
-   ['dev-python/pypy', 'dev-python/pypy-exe-bin'],
mergelist=['dev-python/pypy-exe-bin-7.3.0', 
'dev-python/pypy-7.3.0'],
success = True,
),