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/
@ 2024-09-19 14:41 James Le Cuirot
  0 siblings, 0 replies; 5+ messages in thread
From: James Le Cuirot @ 2024-09-19 14:41 UTC (permalink / raw
  To: gentoo-commits

commit:     a295634be7c0f1eb600780fc19ee7f847fc3a012
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 19 12:12:06 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Thu Sep 19 12:12:31 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a295634b

depgraph: Simplify creation on uninstall tasks

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

 lib/_emerge/Package.py  |  4 ++--
 lib/_emerge/depgraph.py | 26 +++-----------------------
 2 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/lib/_emerge/Package.py b/lib/_emerge/Package.py
index 79011380d5..562f177406 100644
--- a/lib/_emerge/Package.py
+++ b/lib/_emerge/Package.py
@@ -405,7 +405,7 @@ class Package(Task):
             except InvalidData as e:
                 self._invalid_metadata(k + ".syntax", f"{k}: {e}")
 
-    def copy(self):
+    def copy(self, operation=None):
         return Package(
             built=self.built,
             cpv=self.cpv,
@@ -413,7 +413,7 @@ class Package(Task):
             installed=self.installed,
             metadata=self._raw_metadata,
             onlydeps=self.onlydeps,
-            operation=self.operation,
+            operation=operation or self.operation,
             root_config=self.root_config,
             type_name=self.type_name,
         )

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 2acd8f2e13..05bfbbc3e1 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -8936,15 +8936,7 @@ class depgraph:
 
                 if not unresolved_blocks and depends_on_order:
                     for inst_pkg, inst_task in depends_on_order:
-                        uninst_task = Package(
-                            built=inst_pkg.built,
-                            cpv=inst_pkg.cpv,
-                            installed=inst_pkg.installed,
-                            metadata=inst_pkg._metadata,
-                            operation="uninstall",
-                            root_config=inst_pkg.root_config,
-                            type_name=inst_pkg.type_name,
-                        )
+                        uninst_task = inst_pkg.copy(operation="uninstall")
                         # Enforce correct merge order with a hard dep.
                         self._dynamic_config.digraph.addnode(
                             uninst_task, inst_task, priority=BlockerDepPriority.instance
@@ -9965,20 +9957,8 @@ class depgraph:
                     if inst_pkg:
                         # The package will be replaced by this one, so remove
                         # the corresponding Uninstall task if necessary.
-                        inst_pkg = inst_pkg[0]
-                        uninst_task = Package(
-                            built=inst_pkg.built,
-                            cpv=inst_pkg.cpv,
-                            installed=inst_pkg.installed,
-                            metadata=inst_pkg._metadata,
-                            operation="uninstall",
-                            root_config=inst_pkg.root_config,
-                            type_name=inst_pkg.type_name,
-                        )
-                        try:
-                            mygraph.remove(uninst_task)
-                        except KeyError:
-                            pass
+                        uninst_task = inst_pkg[0].copy(operation="uninstall")
+                        mygraph.discard(uninst_task)
 
                 if (
                     uninst_task is not None


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

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

commit:     e5ea1157ba37252e1f0d9e5d82043490b5b77f3c
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 19 16:24:56 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Thu Sep 19 16:24:56 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e5ea1157

WIP Poor attempt at making it handle more than one conflict

The order is wrong and some of the rebuilds randomly disappear.

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

 lib/_emerge/depgraph.py | 47 ++++++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index df01280e30..c2f59b1014 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9224,6 +9224,7 @@ class depgraph:
         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):
             """
@@ -9929,26 +9930,34 @@ class depgraph:
                     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.


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

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

commit:     1fc0810be82be7e7de692e14462d8878cbdf1103
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 19 16:24:56 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 16:19:14 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1fc0810b

WIP Poor attempt at making it handle more than one conflict

The order is wrong and some of the rebuilds randomly disappear.

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

 lib/_emerge/depgraph.py | 52 +++++++++++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 7ca5b3caf3..69ecfa9970 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9224,6 +9224,7 @@ class depgraph:
         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):
             """
@@ -9929,29 +9930,38 @@ class depgraph:
                     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 = set(parent.use.enabled)
-
-                        if solution[1]:
-                            enabled.add(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 = set(changed_pkg.use.enabled)
+
+                            if solution[1]:
+                                enabled.add(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])
+                            self._dynamic_config._circular_deps_for_display = mygraph
+                            self._dynamic_config._need_restart = True
+                            raise self._unknown_internal_error()
 
-                        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()
+                    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.


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

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

commit:     e9a80f8adbcb224f9dd99d00e99236c3ec1074dd
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 23 16:13:31 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 16:19:15 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9a80f8a

WIP Only attempt auto conflict resolution if it involves no new deps

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

 lib/_emerge/depgraph.py | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 69ecfa9970..f4bb55e05a 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9932,6 +9932,7 @@ class depgraph:
                 else:
                     uniq_selected_nodes = set()
                     while True:
+                        changed_pkg = None
                         handler = circular_dependency_handler(self, mygraph)
 
                         if handler.solutions:
@@ -9946,14 +9947,26 @@ class depgraph:
                             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
-                            )
+                            # To avoid unnecessarily complexity, only try to
+                            # automatically resolve the conflict if the solution
+                            # does not pull in additional dependencies.
+                            before = self._flatten_atoms(parent, parent.use.enabled)
+                            after  = self._flatten_atoms(changed_pkg, frozenset(enabled))
+
+                            if before.issuperset(after):
+                                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
+                                )
+                            else:
+                                changed_pkg = None
+
+                        if changed_pkg is not None:
+                            pass
                         elif uniq_selected_nodes:
                             break
                         else:


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

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

commit:     714deff1a048a21e359137b4cc8a20b6d3928d16
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 19 12:12:06 2024 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Sep 23 16:19:12 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=714deff1

depgraph: Simplify creation on uninstall tasks

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

 lib/_emerge/Package.py  |  4 ++--
 lib/_emerge/depgraph.py | 26 +++-----------------------
 2 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/lib/_emerge/Package.py b/lib/_emerge/Package.py
index 79011380d5..562f177406 100644
--- a/lib/_emerge/Package.py
+++ b/lib/_emerge/Package.py
@@ -405,7 +405,7 @@ class Package(Task):
             except InvalidData as e:
                 self._invalid_metadata(k + ".syntax", f"{k}: {e}")
 
-    def copy(self):
+    def copy(self, operation=None):
         return Package(
             built=self.built,
             cpv=self.cpv,
@@ -413,7 +413,7 @@ class Package(Task):
             installed=self.installed,
             metadata=self._raw_metadata,
             onlydeps=self.onlydeps,
-            operation=self.operation,
+            operation=operation or self.operation,
             root_config=self.root_config,
             type_name=self.type_name,
         )

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 2acd8f2e13..05bfbbc3e1 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -8936,15 +8936,7 @@ class depgraph:
 
                 if not unresolved_blocks and depends_on_order:
                     for inst_pkg, inst_task in depends_on_order:
-                        uninst_task = Package(
-                            built=inst_pkg.built,
-                            cpv=inst_pkg.cpv,
-                            installed=inst_pkg.installed,
-                            metadata=inst_pkg._metadata,
-                            operation="uninstall",
-                            root_config=inst_pkg.root_config,
-                            type_name=inst_pkg.type_name,
-                        )
+                        uninst_task = inst_pkg.copy(operation="uninstall")
                         # Enforce correct merge order with a hard dep.
                         self._dynamic_config.digraph.addnode(
                             uninst_task, inst_task, priority=BlockerDepPriority.instance
@@ -9965,20 +9957,8 @@ class depgraph:
                     if inst_pkg:
                         # The package will be replaced by this one, so remove
                         # the corresponding Uninstall task if necessary.
-                        inst_pkg = inst_pkg[0]
-                        uninst_task = Package(
-                            built=inst_pkg.built,
-                            cpv=inst_pkg.cpv,
-                            installed=inst_pkg.installed,
-                            metadata=inst_pkg._metadata,
-                            operation="uninstall",
-                            root_config=inst_pkg.root_config,
-                            type_name=inst_pkg.type_name,
-                        )
-                        try:
-                            mygraph.remove(uninst_task)
-                        except KeyError:
-                            pass
+                        uninst_task = inst_pkg[0].copy(operation="uninstall")
+                        mygraph.discard(uninst_task)
 
                 if (
                     uninst_task is not None


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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19 16:26 [gentoo-commits] proj/portage:use-conflict-auto-resolve commit in: lib/_emerge/ James Le Cuirot
  -- strict thread matches above, loose matches on Subject: below --
2024-09-23 16:21 James Le Cuirot
2024-09-23 16:21 James Le Cuirot
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