Refresh lockfile when --refresh is provided (#15991) (#15994)

## Summary

If you provide `--refresh` to `uv lock`, we'll now always resolve (even
though it might return the same result). This is also robust to
`--locked` such that `--refresh --locked` will only fail if the lockfile
changes.

Closes https://github.com/astral-sh/uv/issues/15997.
This commit is contained in:
Charlie Marsh 2025-09-23 07:25:13 -04:00 committed by GitHub
parent 7f7fac812c
commit 8d6b369274
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 318 additions and 36 deletions

View file

@ -170,7 +170,7 @@ static ANDROID_X86_MARKERS: LazyLock<UniversalMarker> = LazyLock::new(|| {
marker
});
#[derive(Clone, Debug, serde::Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
#[serde(try_from = "LockWire")]
pub struct Lock {
/// The (major) version of the lockfile format.
@ -3233,34 +3233,6 @@ struct PackageMetadata {
dependency_groups: BTreeMap<GroupName, BTreeSet<Requirement>>,
}
impl PackageMetadata {
fn unwire(self, requires_python: &RequiresPython) -> Self {
// We need to complexify these markers so things like
// `requires_python < '0'` get normalized to False
let unwire_requirements = |requirements: BTreeSet<Requirement>| -> BTreeSet<Requirement> {
requirements
.into_iter()
.map(|mut requirement| {
let complexified_marker =
requires_python.complexify_markers(requirement.marker);
requirement.marker = complexified_marker;
requirement
})
.collect()
};
Self {
requires_dist: unwire_requirements(self.requires_dist),
provides_extra: self.provides_extra,
dependency_groups: self
.dependency_groups
.into_iter()
.map(|(group, requirements)| (group, unwire_requirements(requirements)))
.collect(),
}
}
}
impl PackageWire {
fn unwire(
self,
@ -3292,7 +3264,7 @@ impl PackageWire {
Ok(Package {
id: self.id,
metadata: self.metadata.unwire(requires_python),
metadata: self.metadata,
sdist: self.sdist,
wheels: self.wheels,
fork_markers: self
@ -4826,11 +4798,12 @@ impl Dependency {
) -> Self {
let simplified_marker =
SimplifiedMarkerTree::new(requires_python, complexified_marker.combined());
let complexified_marker = simplified_marker.into_marker(requires_python);
Self {
package_id,
extra,
simplified_marker,
complexified_marker,
complexified_marker: UniversalMarker::from_combined(complexified_marker),
}
}