commit:     9823f70c6e4ef3cdd6abb4d9fc599ce02a138125
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 28 23:58:23 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Nov 29 00:00:18 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9823f70c

Prefer installed leaves in runtime cycle topological sort

In order to avoid possibly merging a package too early, prefer
installed leaves in runtime cycle topological sort. This fixes
an AlternativesGzipTestCase failure that arose after 2e298ea7ba36
caused leaves to be selected in a slightly different order.

Bug: https://bugs.gentoo.org/917259
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/depgraph.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index da37f980ad..9f041f83a9 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9498,6 +9498,12 @@ class depgraph:
                     if smallest_leaves is None:
                         smallest_leaves = [cycle_digraph.order[-1]]
 
+                    # Prefer installed leaves, in order to avoid
+                    # merging something too early.
+                    installed_leaves = [pkg for pkg in smallest_leaves if 
pkg.installed]
+                    if installed_leaves:
+                        smallest_leaves = installed_leaves
+
                     # Only harvest one node at a time, in order to
                     # minimize the number of ignored dependencies.
                     cycle_digraph.remove(smallest_leaves[0])

Reply via email to