Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(source): Split RecursivePathSource out of PathSource #13993

Merged
merged 7 commits into from
Jun 3, 2024
3 changes: 1 addition & 2 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,7 @@ impl<'gctx> Workspace<'gctx> {
MaybePackage::Package(ref p) => p.clone(),
MaybePackage::Virtual(_) => continue,
};
let mut src = PathSource::new(pkg.root(), pkg.package_id().source_id(), self.gctx);
src.preload_with(pkg);
let src = PathSource::preload_with(pkg, self.gctx);
registry.add_preloaded(Box::new(src));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use crate::core::PackageSet;
use crate::core::SourceId;
use crate::core::Workspace;
use crate::ops;
use crate::sources::PathSource;
use crate::sources::RecursivePathSource;
use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use crate::util::CanonicalUrl;
Expand Down Expand Up @@ -453,7 +453,7 @@ pub fn add_overrides<'a>(

for (path, definition) in paths {
let id = SourceId::for_path(&path)?;
let mut source = PathSource::new_recursive(&path, id, ws.gctx());
let mut source = RecursivePathSource::new(&path, id, ws.gctx());
source.update().with_context(|| {
format!(
"failed to update path override `{}` \
Expand Down
8 changes: 4 additions & 4 deletions src/cargo/sources/git/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::sources::source::MaybePackage;
use crate::sources::source::QueryKind;
use crate::sources::source::Source;
use crate::sources::IndexSummary;
use crate::sources::PathSource;
use crate::sources::RecursivePathSource;
use crate::util::cache_lock::CacheLockMode;
use crate::util::errors::CargoResult;
use crate::util::hex::short_hash;
Expand All @@ -24,7 +24,7 @@ use tracing::trace;
use url::Url;

/// `GitSource` contains one or more packages gathering from a Git repository.
/// Under the hood it uses [`PathSource`] to discover packages inside the
/// Under the hood it uses [`RecursivePathSource`] to discover packages inside the
/// repository.
///
/// ## Filesystem layout
Expand Down Expand Up @@ -79,7 +79,7 @@ pub struct GitSource<'gctx> {
///
/// This gets set to `Some` after the git repo has been checked out
/// (automatically handled via [`GitSource::block_until_ready`]).
path_source: Option<PathSource<'gctx>>,
path_source: Option<RecursivePathSource<'gctx>>,
/// A short string that uniquely identifies the version of the checkout.
///
/// This is typically a 7-character string of the OID hash, automatically
Expand Down Expand Up @@ -356,7 +356,7 @@ impl<'gctx> Source for GitSource<'gctx> {
let source_id = self
.source_id
.with_git_precise(Some(actual_rev.to_string()));
let path_source = PathSource::new_recursive(&checkout_path, source_id, self.gctx);
let path_source = RecursivePathSource::new(&checkout_path, source_id, self.gctx);

self.path_source = Some(path_source);
self.short_id = Some(short_id.as_str().into());
Expand Down
1 change: 1 addition & 0 deletions src/cargo/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use self::config::SourceConfigMap;
pub use self::directory::DirectorySource;
pub use self::git::GitSource;
pub use self::path::PathSource;
pub use self::path::RecursivePathSource;
pub use self::registry::{
IndexSummary, RegistrySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY,
};
Expand Down
Loading