Use sets rather than vectors for lockfile requirements (#6107)

## Summary

Ensures that `--locked` is robust to reordering and duplicates.
This commit is contained in:
Charlie Marsh 2024-08-15 09:00:35 -04:00 committed by GitHub
parent fd0daae969
commit 29179570a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 500 additions and 349 deletions

View file

@ -35,7 +35,9 @@ pub enum RequirementError {
///
/// The main change is using [`RequirementSource`] to represent all supported package sources over
/// [`VersionOrUrl`], which collapses all URL sources into a single stringly type.
#[derive(Hash, Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(
Hash, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, serde::Deserialize,
)]
pub struct Requirement {
pub name: PackageName,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
@ -294,7 +296,9 @@ impl Display for Requirement {
/// We store both the parsed fields (such as the plain url and the subdirectory) and the joined
/// PEP 508 style url (e.g. `file:///<path>#subdirectory=<subdirectory>`) since we need both in
/// different locations.
#[derive(Hash, Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(
Hash, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, serde::Deserialize,
)]
#[serde(try_from = "RequirementSourceWire", into = "RequirementSourceWire")]
pub enum RequirementSource {
/// The requirement has a version specifier, such as `foo >1,<2`.