Skip to content

Commit

Permalink
depgraph: Simplify creation on uninstall tasks
Browse files Browse the repository at this point in the history
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
  • Loading branch information
chewi committed Sep 19, 2024
1 parent b0ceebc commit a295634
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/_emerge/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,15 @@ def _validate_deps(self):
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,
depth=self.depth,
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,
)
Expand Down
26 changes: 3 additions & 23 deletions lib/_emerge/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8936,15 +8936,7 @@ def _validate_blockers(self):

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
Expand Down Expand Up @@ -9965,20 +9957,8 @@ def find_smallest_cycle(mergeable_nodes, local_priority_range):
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
Expand Down

0 comments on commit a295634

Please sign in to comment.