Skip to content

Commit

Permalink
WIP Poor attempt at making it handle more than one conflict
Browse files Browse the repository at this point in the history
The order is wrong and some of the rebuilds randomly disappear.

Signed-off-by: James Le Cuirot <chewi@gentoo.org>
  • Loading branch information
chewi committed Sep 19, 2024
1 parent 9177067 commit e5ea115
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions lib/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9224,6 +9224,7 @@ def _serialize_tasks(self):
complete = "complete" in self._dynamic_config.myparams
ignore_world = self._dynamic_config.myparams.get("ignore_world", False)
asap_nodes = []
changed_pkgs = {}

def get_nodes(**kwargs):
"""
Expand Down Expand Up @@ -9929,26 +9930,34 @@ def find_smallest_cycle(mergeable_nodes, local_priority_range):
self._dynamic_config._skip_restart = True
raise self._unknown_internal_error()
else:
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])
uniq_selected_nodes = set()
while True:
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]
changed_pkg = changed_pkgs.get(parent, parent)
enabled = list(changed_pkg.use.enabled)
if solution[1]:
enabled.append(solution[0])
else:
enabled.remove(solution[0])
changed_pkgs[parent] = changed_pkg.with_use(enabled)
uniq_selected_nodes.update((pkg, parent))
mygraph.remove_edge(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
)
elif uniq_selected_nodes:
break
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()
self._dynamic_config._circular_deps_for_display = mygraph
self._dynamic_config._need_restart = True
raise self._unknown_internal_error()
selected_nodes = list(changed_pkgs.values()) + list(uniq_selected_nodes)

# At this point, we've succeeded in selecting one or more nodes, so
# reset state variables for leaf node selection.
Expand Down

0 comments on commit e5ea115

Please sign in to comment.