public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:use-conflict-auto-resolve commit in: lib/_emerge/resolver/, lib/_emerge/
@ 2024-09-19 14:41 James Le Cuirot
  0 siblings, 0 replies; 3+ messages in thread
From: James Le Cuirot @ 2024-09-19 14:41 UTC (permalink / raw
  To: gentoo-commits

commit:     994e109177b1b4209d8a64429ca7b01504be168a
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 18 11:21:55 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Thu Sep 19 12:42:41 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=994e1091

WIP Auto resolve cyclic USE conflicts by trying the first suggestion

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 lib/_emerge/depgraph.py                     | 27 ++++++++++++++++++++++-----
 lib/_emerge/resolver/circular_dependency.py |  2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 05bfbbc3e1..fe686a104c 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9901,8 +9901,6 @@ class depgraph:
                     continue
 
             if not selected_nodes:
-                self._dynamic_config._circular_deps_for_display = mygraph
-
                 unsolved_cycle = False
                 if self._dynamic_config._allow_backtracking:
                     backtrack_infos = self._dynamic_config._backtrack_infos
@@ -9927,11 +9925,30 @@ class depgraph:
                             )
 
                 if unsolved_cycle or not self._dynamic_config._allow_backtracking:
+                    self._dynamic_config._circular_deps_for_display = mygraph
                     self._dynamic_config._skip_restart = True
+                    raise self._unknown_internal_error()
                 else:
-                    self._dynamic_config._need_restart = True
-
-                raise self._unknown_internal_error()
+                    handler = circular_dependency_handler(self, mygraph)
+                    if handler.solutions:
+                        pkg = list(handler.solutions.keys())[0]
+                        parent, solution = list(handler.solutions[pkg])[0]
+                        solution = list(solution)[0]
+                        enabled = list(parent.use.enabled)
+                        if solution[1]:
+                            enabled.append(solution[0])
+                        else:
+                            enabled.remove(solution[0])
+                        selected_nodes = [parent.with_use(enabled), pkg, parent]
+                        ignored_uninstall_tasks = set(
+                            uninst_task
+                            for uninst_task in ignored_uninstall_tasks
+                            if uninst_task.cp != pkg.cp or uninst_task.slot != pkg.slot
+                        )
+                    else:
+                        self._dynamic_config._circular_deps_for_display = mygraph
+                        self._dynamic_config._need_restart = True
+                        raise self._unknown_internal_error()
 
             # At this point, we've succeeded in selecting one or more nodes, so
             # reset state variables for leaf node selection.

diff --git a/lib/_emerge/resolver/circular_dependency.py b/lib/_emerge/resolver/circular_dependency.py
index 6c21423083..09b1afebfb 100644
--- a/lib/_emerge/resolver/circular_dependency.py
+++ b/lib/_emerge/resolver/circular_dependency.py
@@ -293,7 +293,7 @@ class circular_dependency_handler:
                         " (This change might require USE changes on parent packages.)"
                     )
                 suggestions.append(msg)
-                final_solutions.setdefault(pkg, set()).add(solution)
+                final_solutions.setdefault(pkg, set()).add((parent, solution))
 
         return final_solutions, suggestions
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:use-conflict-auto-resolve commit in: lib/_emerge/resolver/, lib/_emerge/
@ 2024-09-19 15:06 James Le Cuirot
  0 siblings, 0 replies; 3+ messages in thread
From: James Le Cuirot @ 2024-09-19 15:06 UTC (permalink / raw
  To: gentoo-commits

commit:     9177067b75b03bd10c4baaf882843cfacd3e8c62
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 18 11:21:55 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Thu Sep 19 15:05:10 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9177067b

WIP Auto resolve cyclic USE conflicts by trying the first suggestion

It only works when there is one conflicting cycle. It gets too
complicated when there is more than one.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 lib/_emerge/depgraph.py                     | 27 ++++++++++++++++++++++-----
 lib/_emerge/resolver/circular_dependency.py |  2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 05bfbbc3e1..df01280e30 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9901,8 +9901,6 @@ class depgraph:
                     continue
 
             if not selected_nodes:
-                self._dynamic_config._circular_deps_for_display = mygraph
-
                 unsolved_cycle = False
                 if self._dynamic_config._allow_backtracking:
                     backtrack_infos = self._dynamic_config._backtrack_infos
@@ -9927,11 +9925,30 @@ class depgraph:
                             )
 
                 if unsolved_cycle or not self._dynamic_config._allow_backtracking:
+                    self._dynamic_config._circular_deps_for_display = mygraph
                     self._dynamic_config._skip_restart = True
+                    raise self._unknown_internal_error()
                 else:
-                    self._dynamic_config._need_restart = True
-
-                raise self._unknown_internal_error()
+                    handler = circular_dependency_handler(self, mygraph)
+                    if handler.solutions and len(handler.cycles) == 2:
+                        pkg = list(handler.solutions.keys())[0]
+                        parent, solution = list(handler.solutions[pkg])[0]
+                        solution = list(solution)[0]
+                        enabled = list(parent.use.enabled)
+                        if solution[1]:
+                            enabled.append(solution[0])
+                        else:
+                            enabled.remove(solution[0])
+                        selected_nodes = [parent.with_use(enabled), pkg, parent]
+                        ignored_uninstall_tasks = set(
+                            uninst_task
+                            for uninst_task in ignored_uninstall_tasks
+                            if uninst_task.cp != pkg.cp or uninst_task.slot != pkg.slot
+                        )
+                    else:
+                        self._dynamic_config._circular_deps_for_display = mygraph
+                        self._dynamic_config._need_restart = True
+                        raise self._unknown_internal_error()
 
             # At this point, we've succeeded in selecting one or more nodes, so
             # reset state variables for leaf node selection.

diff --git a/lib/_emerge/resolver/circular_dependency.py b/lib/_emerge/resolver/circular_dependency.py
index 6c21423083..09b1afebfb 100644
--- a/lib/_emerge/resolver/circular_dependency.py
+++ b/lib/_emerge/resolver/circular_dependency.py
@@ -293,7 +293,7 @@ class circular_dependency_handler:
                         " (This change might require USE changes on parent packages.)"
                     )
                 suggestions.append(msg)
-                final_solutions.setdefault(pkg, set()).add(solution)
+                final_solutions.setdefault(pkg, set()).add((parent, solution))
 
         return final_solutions, suggestions
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:use-conflict-auto-resolve commit in: lib/_emerge/resolver/, lib/_emerge/
@ 2024-09-23 16:21 James Le Cuirot
  0 siblings, 0 replies; 3+ messages in thread
From: James Le Cuirot @ 2024-09-23 16:21 UTC (permalink / raw
  To: gentoo-commits

commit:     a4bc418f9c6a00c7b67209f37cad990e144d7478
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 18 11:21:55 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 16:19:13 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a4bc418f

WIP Auto resolve cyclic USE conflicts by trying the first suggestion

It only works when there is one conflicting cycle. It gets too
complicated when there is more than one.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 lib/_emerge/depgraph.py                     | 28 ++++++++++++++++++++++++----
 lib/_emerge/resolver/circular_dependency.py |  2 +-
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 05bfbbc3e1..7ca5b3caf3 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9901,8 +9901,6 @@ class depgraph:
                     continue
 
             if not selected_nodes:
-                self._dynamic_config._circular_deps_for_display = mygraph
-
                 unsolved_cycle = False
                 if self._dynamic_config._allow_backtracking:
                     backtrack_infos = self._dynamic_config._backtrack_infos
@@ -9927,11 +9925,33 @@ class depgraph:
                             )
 
                 if unsolved_cycle or not self._dynamic_config._allow_backtracking:
+                    self._dynamic_config._circular_deps_for_display = mygraph
                     self._dynamic_config._skip_restart = True
+                    raise self._unknown_internal_error()
                 else:
-                    self._dynamic_config._need_restart = True
+                    handler = circular_dependency_handler(self, mygraph)
 
-                raise self._unknown_internal_error()
+                    if handler.solutions and len(handler.cycles) == 2:
+                        pkg = list(handler.solutions.keys())[0]
+                        parent, solution = list(handler.solutions[pkg])[0]
+                        solution = list(solution)[0]
+                        enabled = set(parent.use.enabled)
+
+                        if solution[1]:
+                            enabled.add(solution[0])
+                        else:
+                            enabled.remove(solution[0])
+
+                        selected_nodes = [parent.with_use(enabled), pkg, parent]
+                        ignored_uninstall_tasks = set(
+                            uninst_task
+                            for uninst_task in ignored_uninstall_tasks
+                            if uninst_task.cp != pkg.cp or uninst_task.slot != pkg.slot
+                        )
+                    else:
+                        self._dynamic_config._circular_deps_for_display = mygraph
+                        self._dynamic_config._need_restart = True
+                        raise self._unknown_internal_error()
 
             # At this point, we've succeeded in selecting one or more nodes, so
             # reset state variables for leaf node selection.

diff --git a/lib/_emerge/resolver/circular_dependency.py b/lib/_emerge/resolver/circular_dependency.py
index 6c21423083..09b1afebfb 100644
--- a/lib/_emerge/resolver/circular_dependency.py
+++ b/lib/_emerge/resolver/circular_dependency.py
@@ -293,7 +293,7 @@ class circular_dependency_handler:
                         " (This change might require USE changes on parent packages.)"
                     )
                 suggestions.append(msg)
-                final_solutions.setdefault(pkg, set()).add(solution)
+                final_solutions.setdefault(pkg, set()).add((parent, solution))
 
         return final_solutions, suggestions
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-23 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 15:06 [gentoo-commits] proj/portage:use-conflict-auto-resolve commit in: lib/_emerge/resolver/, lib/_emerge/ James Le Cuirot
  -- strict thread matches above, loose matches on Subject: below --
2024-09-23 16:21 James Le Cuirot
2024-09-19 14:41 James Le Cuirot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox