Skip to content

Commit

Permalink
WIP Auto resolve cyclic USE conflicts by trying the first suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: James Le Cuirot <[email protected]>
  • Loading branch information
chewi committed Sep 19, 2024
1 parent a295634 commit 994e109
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions lib/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9901,8 +9901,6 @@ def find_smallest_cycle(mergeable_nodes, local_priority_range):
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
Expand All @@ -9927,11 +9925,30 @@ def find_smallest_cycle(mergeable_nodes, local_priority_range):
)

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.
Expand Down
2 changes: 1 addition & 1 deletion lib/_emerge/resolver/circular_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _find_suggestions(self):
" (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

Expand Down

0 comments on commit 994e109

Please sign in to comment.