Skip to content

Commit

Permalink
Use specific terminology for sparse HTTP-based registry
Browse files Browse the repository at this point in the history
Git-based registry uses HTTP too
  • Loading branch information
kornelski committed Jun 17, 2022
1 parent 17f8088 commit a9faf49
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(<target>)'.dependencies]`
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)?,
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/source/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SourceId> {
if config.cli_unstable().http_registry {
/// sparse HTTP index if allowed.
pub fn crates_io_maybe_sparse_http(config: &Config) -> CargoResult<SourceId> {
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))
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/sources/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)?;
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/sources/registry/http_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ impl<'cfg> HttpRegistry<'cfg> {
config: &'cfg Config,
name: &str,
) -> CargoResult<HttpRegistry<'cfg>> {
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.
Expand Down
14 changes: 7 additions & 7 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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`.)
unstable and require `-Zunstable-options`.)
6 changes: 3 additions & 3 deletions tests/testsuite/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a9faf49

Please sign in to comment.