From 92735ced9a9ee998d048a2c4fde72eda80f05cbe Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 14 Nov 2024 16:24:03 -0500 Subject: [PATCH] Misc. touch-ups to target-to-resolution routine (#9131) --- crates/uv-resolver/src/lock/target.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/uv-resolver/src/lock/target.rs b/crates/uv-resolver/src/lock/target.rs index 03bfabcef..46466c7f7 100644 --- a/crates/uv-resolver/src/lock/target.rs +++ b/crates/uv-resolver/src/lock/target.rs @@ -216,7 +216,7 @@ impl<'env> InstallTarget<'env> { let dep_dist = self.lock().find_by_id(&dep.package_id); - // Add the dependency to the graph. + // Add the package to the graph. let dep_index = match inverse.entry(&dep.package_id) { Entry::Vacant(entry) => { let index = petgraph.add_node(self.package_to_node( @@ -275,7 +275,7 @@ impl<'env> InstallTarget<'env> { name: root_name.clone(), })?; - // Add the workspace package to the graph. + // Add the package to the graph. let index = match inverse.entry(&dist.id) { Entry::Vacant(entry) => { let index = petgraph.add_node(self.package_to_node( @@ -293,7 +293,7 @@ impl<'env> InstallTarget<'env> { } }; - // Add an edge from the root. + // Add the edge. petgraph.add_edge( root, index, @@ -301,9 +301,13 @@ impl<'env> InstallTarget<'env> { ); // Push its dependencies on the queue. - queue.push_back((dist, None)); + if seen.insert((&dist.id, None)) { + queue.push_back((dist, None)); + } for extra in &dependency.extras { - queue.push_back((dist, Some(extra))); + if seen.insert((&dist.id, Some(extra))) { + queue.push_back((dist, Some(extra))); + } } } }