Skip to content

Commit 3a76e49

Browse files
authored
Get rid of Lock::with_manifest, make Lock::from_resolution take the manifest (#21132)
## Summary Minor cleanup related to #20631. ## Test Plan Existing coverage.
1 parent 7e6caa4 commit 3a76e49

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

‎crates/uv-resolver/src/lock/mod.rs‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,13 @@ impl<'lock> DependencySelection<'lock> {
986986
}
987987

988988
impl Lock {
989-
/// Initialize a [`Lock`] from a [`ResolverOutput`], applying any index-specific hash
990-
/// requirements to registry artifacts.
989+
/// Initialize a [`Lock`] from a [`ResolverOutput`] and [`ResolverManifest`], applying any
990+
/// index-specific hash requirements to registry artifacts.
991991
///
992992
/// Returns an error if an artifact does not advertise its index's required algorithm.
993993
pub fn from_resolution(
994994
resolution: &ResolverOutput,
995+
manifest: ResolverManifest,
995996
root: &Path,
996997
supported_environments: Vec<MarkerTree>,
997998
index_locations: &IndexLocations,
@@ -1141,7 +1142,7 @@ impl Lock {
11411142
packages,
11421143
requires_python,
11431144
options,
1144-
ResolverManifest::default(),
1145+
manifest,
11451146
Conflicts::empty(),
11461147
supported_environments,
11471148
vec![],
@@ -1293,13 +1294,6 @@ impl Lock {
12931294
Ok(lock)
12941295
}
12951296

1296-
/// Record the requirements that were used to generate this lock.
1297-
#[must_use]
1298-
pub fn with_manifest(mut self, manifest: ResolverManifest) -> Self {
1299-
self.manifest = manifest;
1300-
self
1301-
}
1302-
13031297
/// Record the conflicting groups that were used to generate this lock.
13041298
#[must_use]
13051299
pub fn with_conflicts(mut self, conflicts: Conflicts) -> Self {

‎crates/uv/src/commands/project/lock.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,11 @@ async fn do_lock(
11081108
let previous = existing_lock.map(ValidatedLock::into_lock);
11091109
let lock = Lock::from_resolution(
11101110
&resolution,
1111+
manifest,
11111112
target.install_path(),
11121113
lock_supported_environments.clone().into_markers(),
11131114
index_locations,
11141115
)?
1115-
.with_manifest(manifest)
11161116
.with_conflicts(conflicts)
11171117
.with_required_environments(lock_required_environments.into_markers());
11181118

‎crates/uv/src/commands/tool/common.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ impl ToolLock {
338338
manifest: &ResolverManifest,
339339
index_locations: &IndexLocations,
340340
) -> anyhow::Result<Self> {
341-
let lock = Lock::from_resolution(resolution, root, Vec::new(), index_locations)?;
342341
let manifest = manifest.clone().relative_to(root)?;
342+
let lock = Lock::from_resolution(resolution, manifest, root, Vec::new(), index_locations)?;
343343
Ok(Self {
344344
root: root.to_path_buf(),
345-
lock: lock.with_manifest(manifest),
345+
lock,
346346
})
347347
}
348348

0 commit comments

Comments
 (0)