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