From a9faf49040467cc725e27184f6ae22754246d7f1 Mon Sep 17 00:00:00 2001 From: Kornel Date: Fri, 17 Jun 2022 15:09:56 +0100 Subject: [PATCH 1/2] Use specific terminology for sparse HTTP-based registry Git-based registry uses HTTP too --- CHANGELOG.md | 2 +- src/cargo/core/features.rs | 4 ++-- src/cargo/core/source/source_id.rs | 6 +++--- src/cargo/sources/config.rs | 6 +++--- src/cargo/sources/registry/http_remote.rs | 4 ++-- src/doc/src/reference/unstable.md | 14 +++++++------- tests/testsuite/registry.rs | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 669474c01fd..658c08198b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -157,7 +157,7 @@ - Start work on inheriting manifest values in a workspace. [#10497](https://github.com/rust-lang/cargo/pull/10497) [#10517](https://github.com/rust-lang/cargo/pull/10517) -- Added support for HTTP registries. +- Added support for sparse HTTP registries. [#10470](https://github.com/rust-lang/cargo/pull/10470) [#10064](https://github.com/rust-lang/cargo/pull/10064) - Fixed panic when artifact target is used for `[target.'cfg()'.dependencies]` diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 53786eff3ff..779bca4ce02 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -653,7 +653,7 @@ unstable_cli_options!( no_index_update: bool = ("Do not update the registry index even if the cache is outdated"), panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"), host_config: bool = ("Enable the [host] section in the .cargo/config.toml file"), - http_registry: bool = ("Support HTTP-based crate registries"), + sparse_registry: bool = ("Support plain-HTTP-based crate registries"), target_applies_to_host: bool = ("Enable the `target-applies-to-host` key in the .cargo/config.toml file"), rustdoc_map: bool = ("Allow passing external documentation mappings to rustdoc"), separate_nightlies: bool = (HIDDEN), @@ -907,7 +907,7 @@ impl CliUnstable { "multitarget" => self.multitarget = parse_empty(k, v)?, "rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?, "terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?), - "http-registry" => self.http_registry = parse_empty(k, v)?, + "sparse-registry" => self.sparse_registry = parse_empty(k, v)?, "namespaced-features" => stabilized_warn(k, "1.60", STABILISED_NAMESPACED_FEATURES), "weak-dep-features" => stabilized_warn(k, "1.60", STABILIZED_WEAK_DEP_FEATURES), "credential-process" => self.credential_process = parse_empty(k, v)?, diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 653685b8bec..c51a67c5074 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -208,9 +208,9 @@ impl SourceId { } /// Returns the `SourceId` corresponding to the main repository, using the - /// http index if allowed. - pub fn crates_io_maybe_http(config: &Config) -> CargoResult { - if config.cli_unstable().http_registry { + /// sparse HTTP index if allowed. + pub fn crates_io_maybe_sparse_http(config: &Config) -> CargoResult { + if config.cli_unstable().sparse_registry { config.check_registry_index_not_set()?; let url = CRATES_IO_HTTP_INDEX.into_url().unwrap(); SourceId::new(SourceKind::Registry, url, Some(CRATES_IO_REGISTRY)) diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index ff3b9ccb957..6d6c7ee3944 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -91,11 +91,11 @@ impl<'cfg> SourceConfigMap<'cfg> { replace_with: None, }, )?; - if config.cli_unstable().http_registry { + if config.cli_unstable().sparse_registry { base.add( CRATES_IO_REGISTRY, SourceConfig { - id: SourceId::crates_io_maybe_http(config)?, + id: SourceId::crates_io_maybe_sparse_http(config)?, replace_with: None, }, )?; @@ -257,7 +257,7 @@ restore the source replacement configuration to continue the build check_not_set("rev", def.rev)?; } if name == CRATES_IO_REGISTRY && srcs.is_empty() { - srcs.push(SourceId::crates_io_maybe_http(self.config)?); + srcs.push(SourceId::crates_io_maybe_sparse_http(self.config)?); } match srcs.len() { diff --git a/src/cargo/sources/registry/http_remote.rs b/src/cargo/sources/registry/http_remote.rs index 18734ef6ba0..b886c006853 100644 --- a/src/cargo/sources/registry/http_remote.rs +++ b/src/cargo/sources/registry/http_remote.rs @@ -131,8 +131,8 @@ impl<'cfg> HttpRegistry<'cfg> { config: &'cfg Config, name: &str, ) -> CargoResult> { - if !config.cli_unstable().http_registry { - anyhow::bail!("usage of HTTP-based registries requires `-Z http-registry`"); + if !config.cli_unstable().sparse_registry { + anyhow::bail!("usage of HTTP-based registries requires `-Z sparse-registry`"); } let url = source_id.url().as_str(); // Ensure the url ends with a slash so we can concatenate paths. diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 6bd68b8a24f..bbdc15719b3 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -102,7 +102,7 @@ Each new feature described below should explain how to use it. * Registries * [credential-process](#credential-process) — Adds support for fetching registry tokens from an external authentication program. * [`cargo logout`](#cargo-logout) — Adds the `logout` command to remove the currently saved registry token. - * [http-registry](#http-registry) — Adds support for fetching from http registries (`sparse+`) + * [sparse-registry](#sparse-registry) — Adds support for fetching from static-file HTTP registries (`sparse+`) ### allow-features @@ -909,18 +909,18 @@ fn main() { } ``` -### http-registry +### sparse-registry * Tracking Issue: [9069](https://github.com/rust-lang/cargo/issues/9069) * RFC: [#2789](https://github.com/rust-lang/rfcs/pull/2789) -The `http-registry` feature allows cargo to interact with remote registries served -over http rather than git. These registries can be identified by urls starting with +The `sparse-registry` feature allows cargo to interact with remote registries served +over plain HTTP rather than git. These registries can be identified by urls starting with `sparse+http://` or `sparse+https://`. -When fetching index metadata over http, cargo only downloads the metadata for relevant +When fetching index metadata over HTTP, cargo only downloads the metadata for relevant crates, which can save significant time and bandwidth. -The format of the http index is identical to a checkout of a git-based index. +The format of the sparse index is identical to a checkout of a git-based index. ### credential-process * Tracking Issue: [#8933](https://github.com/rust-lang/cargo/issues/8933) @@ -1597,4 +1597,4 @@ See the [Features chapter](features.md#dependency-features) for more information The `-Ztimings` option has been stabilized as `--timings` in the 1.60 release. (`--timings=html` and the machine-readable `--timings=json` output remain -unstable and require `-Zunstable-options`.) \ No newline at end of file +unstable and require `-Zunstable-options`.) diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index bf0335cc4cc..f05ce9ba223 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -14,7 +14,7 @@ use std::path::Path; fn cargo_http(p: &Project, s: &str) -> Execs { let mut e = p.cargo(s); - e.arg("-Zhttp-registry").masquerade_as_nightly_cargo(); + e.arg("-Zsparse-registry").masquerade_as_nightly_cargo(); e } @@ -2643,13 +2643,13 @@ fn http_requires_z_flag() { p.cargo("build") .with_status(101) - .with_stderr_contains(" usage of HTTP-based registries requires `-Z http-registry`") + .with_stderr_contains(" usage of HTTP-based registries requires `-Z sparse-registry`") .run(); } #[cargo_test] fn http_requires_trailing_slash() { - cargo_process("-Z http-registry install bar --index sparse+https://index.crates.io") + cargo_process("-Z sparse-registry install bar --index sparse+https://index.crates.io") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr("[ERROR] registry url must end in a slash `/`: sparse+https://index.crates.io") From 288856b778585163f900fa9f2b90c710e44a4a22 Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Fri, 17 Jun 2022 12:20:00 -0400 Subject: [PATCH 2/2] HTTP-based -> sparse Co-authored-by: Arlo Siemsen --- src/cargo/sources/registry/http_remote.rs | 2 +- tests/testsuite/registry.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cargo/sources/registry/http_remote.rs b/src/cargo/sources/registry/http_remote.rs index b886c006853..0a6de7c1bcf 100644 --- a/src/cargo/sources/registry/http_remote.rs +++ b/src/cargo/sources/registry/http_remote.rs @@ -132,7 +132,7 @@ impl<'cfg> HttpRegistry<'cfg> { name: &str, ) -> CargoResult> { if !config.cli_unstable().sparse_registry { - anyhow::bail!("usage of HTTP-based registries requires `-Z sparse-registry`"); + anyhow::bail!("usage of sparse registries requires `-Z sparse-registry`"); } let url = source_id.url().as_str(); // Ensure the url ends with a slash so we can concatenate paths. diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index f05ce9ba223..2f80f778c40 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -2643,7 +2643,7 @@ fn http_requires_z_flag() { p.cargo("build") .with_status(101) - .with_stderr_contains(" usage of HTTP-based registries requires `-Z sparse-registry`") + .with_stderr_contains(" usage of sparse registries requires `-Z sparse-registry`") .run(); }