Skip to content

Commit 737382d

Browse files
committed
Stabilize Alternative Registries
1 parent 0a962f2 commit 737382d

31 files changed

+281
-401
lines changed

src/cargo/core/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ features! {
173173
[unstable] test_dummy_unstable: bool,
174174

175175
// Downloading packages from alternative registry indexes.
176-
[unstable] alternative_registries: bool,
176+
[stable] alternative_registries: bool,
177177

178178
// Using editions
179179
[stable] edition: bool,

src/cargo/ops/registry.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ pub fn search(
721721
prefix
722722
}
723723

724-
let (mut registry, _) = registry(config, None, index, reg, false)?;
724+
let (mut registry, source_id) = registry(config, None, index, reg, false)?;
725725
let (crates, total_crates) = registry
726726
.search(query, limit)
727727
.chain_err(|| "failed to retrieve search results from the registry")?;
@@ -762,11 +762,15 @@ pub fn search(
762762
total_crates - limit
763763
);
764764
} else if total_crates > limit && limit >= search_max_limit {
765-
println!(
766-
"... and {} crates more (go to http://crates.io/search?q={} to see more)",
767-
total_crates - limit,
768-
percent_encode(query.as_bytes(), QUERY_ENCODE_SET)
769-
);
765+
let extra = if source_id.is_default_registry() {
766+
format!(
767+
" (go to http://crates.io/search?q={} to see more)",
768+
percent_encode(query.as_bytes(), QUERY_ENCODE_SET)
769+
)
770+
} else {
771+
String::new()
772+
};
773+
println!("... and {} crates more{}", total_crates - limit, extra);
770774
}
771775

772776
Ok(())

src/cargo/util/command_prelude.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub trait AppExt: Sized {
174174
}
175175

176176
fn arg_index(self) -> Self {
177-
self._arg(opt("index", "Registry index to upload the package to").value_name("INDEX"))
177+
self._arg(opt("index", "Registry index URL to upload the package to").value_name("INDEX"))
178178
._arg(
179179
opt("host", "DEPRECATED, renamed to '--index'")
180180
.value_name("HOST")
@@ -387,12 +387,6 @@ pub trait ArgMatchesExt {
387387
fn registry(&self, config: &Config) -> CargoResult<Option<String>> {
388388
match self._value_of("registry") {
389389
Some(registry) => {
390-
if !config.cli_unstable().unstable_options {
391-
return Err(failure::format_err!(
392-
"registry option is an unstable feature and \
393-
requires -Zunstable-options to use."
394-
));
395-
}
396390
validate_package_name(registry, "registry name", "")?;
397391

398392
if registry == CRATES_IO_REGISTRY {

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -995,14 +995,7 @@ impl TomlManifest {
995995
};
996996
let profiles = Profiles::new(me.profile.as_ref(), config, &features, &mut warnings)?;
997997
let publish = match project.publish {
998-
Some(VecStringOrBool::VecString(ref vecstring)) => {
999-
features
1000-
.require(Feature::alternative_registries())
1001-
.chain_err(|| {
1002-
"the `publish` manifest key is unstable for anything other than a value of true or false"
1003-
})?;
1004-
Some(vecstring.clone())
1005-
}
998+
Some(VecStringOrBool::VecString(ref vecstring)) => Some(vecstring.clone()),
1006999
Some(VecStringOrBool::Bool(false)) => Some(vec![]),
10071000
None | Some(VecStringOrBool::Bool(true)) => None,
10081001
};
@@ -1410,12 +1403,10 @@ impl DetailedTomlDependency {
14101403
.set_optional(self.optional.unwrap_or(false))
14111404
.set_platform(cx.platform.clone());
14121405
if let Some(registry) = &self.registry {
1413-
cx.features.require(Feature::alternative_registries())?;
14141406
let registry_id = SourceId::alt_registry(cx.config, registry)?;
14151407
dep.set_registry_id(registry_id);
14161408
}
14171409
if let Some(registry_index) = &self.registry_index {
1418-
cx.features.require(Feature::alternative_registries())?;
14191410
let url = registry_index.to_url()?;
14201411
let registry_id = SourceId::for_registry(&url)?;
14211412
dep.set_registry_id(registry_id);

src/doc/man/generated/cargo-init.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ <h3 id="cargo_init_init_options">Init Options</h3>
128128
</dd>
129129
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
130130
<dd>
131-
<p>Alternative registry to use. This sets the <code>publish</code> field which will
132-
restrict publishing only to the given registry name.</p>
131+
<p>This sets the <code>publish</code> field in <code>Cargo.toml</code> to the given registry name
132+
which will restrict publishing only to that registry.</p>
133133
<div class="paragraph">
134-
<p>This option is unstable and available only on the nightly channel and requires
135-
the <code>-Z unstable-options</code> flag to enable.</p>
134+
<p>Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
135+
If not specified, the default registry defined by the <code>registry.default</code>
136+
config key is used. If the default registry is not set and <code>--registry</code> is not
137+
used, the <code>publish</code> field will not be set which means that publishing will not
138+
be restricted.</p>
136139
</div>
137140
</dd>
138141
</dl>

src/doc/man/generated/cargo-install.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ <h3 id="cargo_install_install_options">Install Options</h3>
131131
</dd>
132132
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
133133
<dd>
134-
<p>Alternative registry to use.</p>
135-
<div class="paragraph">
136-
<p>This option is unstable and available only on the nightly channel and requires
137-
the <code>-Z unstable-options</code> flag to enable.</p>
138-
</div>
134+
<p>Name of the registry to use. Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
135+
If not specified, the default registry is used, which is defined by the
136+
<code>registry.default</code> config key which defaults to <code>crates-io</code>.</p>
139137
</dd>
140138
</dl>
141139
</div>

src/doc/man/generated/cargo-login.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ <h3 id="cargo_login_login_options">Login Options</h3>
3939
<dl>
4040
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
4141
<dd>
42-
<p>Alternative registry to use.</p>
43-
<div class="paragraph">
44-
<p>This option is unstable and available only on the nightly channel and requires
45-
the <code>-Z unstable-options</code> flag to enable.</p>
46-
</div>
42+
<p>Name of the registry to use. Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
43+
If not specified, the default registry is used, which is defined by the
44+
<code>registry.default</code> config key which defaults to <code>crates-io</code>.</p>
4745
</dd>
4846
</dl>
4947
</div>

src/doc/man/generated/cargo-new.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ <h3 id="cargo_new_new_options">New Options</h3>
121121
</dd>
122122
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
123123
<dd>
124-
<p>Alternative registry to use. This sets the <code>publish</code> field which will
125-
restrict publishing only to the given registry name.</p>
124+
<p>This sets the <code>publish</code> field in <code>Cargo.toml</code> to the given registry name
125+
which will restrict publishing only to that registry.</p>
126126
<div class="paragraph">
127-
<p>This option is unstable and available only on the nightly channel and requires
128-
the <code>-Z unstable-options</code> flag to enable.</p>
127+
<p>Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
128+
If not specified, the default registry defined by the <code>registry.default</code>
129+
config key is used. If the default registry is not set and <code>--registry</code> is not
130+
used, the <code>publish</code> field will not be set which means that publishing will not
131+
be restricted.</p>
129132
</div>
130133
</dd>
131134
</dl>

src/doc/man/generated/cargo-owner.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,24 @@ <h3 id="cargo_owner_owner_options">Owner Options</h3>
5858
</dd>
5959
<dt class="hdlist1"><strong>--token</strong> <em>TOKEN</em></dt>
6060
<dd>
61-
<p>API token to use when authenticating.</p>
61+
<p>API token to use when authenticating. This overrides the token stored in
62+
the credentials file (which is created by <a href="commands/cargo-login.html">cargo-login(1)</a>).</p>
63+
<div class="paragraph">
64+
<p>The token for crates.io may be specified with the <code>CARGO_REGISTRY_TOKEN</code>
65+
environment variable. Tokens for other registries may be specified with
66+
environment variables of the form <code>CARGO_REGISTRIES_NAME_TOKEN</code> where <code>NAME</code>
67+
is the name of the registry in all capital letters.</p>
68+
</div>
6269
</dd>
6370
<dt class="hdlist1"><strong>--index</strong> <em>INDEX</em></dt>
6471
<dd>
6572
<p>The URL of the registry index to use.</p>
6673
</dd>
6774
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
6875
<dd>
69-
<p>Alternative registry to use.</p>
70-
<div class="paragraph">
71-
<p>This option is unstable and available only on the nightly channel and requires
72-
the <code>-Z unstable-options</code> flag to enable.</p>
73-
</div>
76+
<p>Name of the registry to use. Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
77+
If not specified, the default registry is used, which is defined by the
78+
<code>registry.default</code> config key which defaults to <code>crates-io</code>.</p>
7479
</dd>
7580
</dl>
7681
</div>

src/doc/man/generated/cargo-publish.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ <h3 id="cargo_publish_publish_options">Publish Options</h3>
6767
</dd>
6868
<dt class="hdlist1"><strong>--token</strong> <em>TOKEN</em></dt>
6969
<dd>
70-
<p>API token to use when authenticating.</p>
70+
<p>API token to use when authenticating. This overrides the token stored in
71+
the credentials file (which is created by <a href="commands/cargo-login.html">cargo-login(1)</a>).</p>
72+
<div class="paragraph">
73+
<p>The token for crates.io may be specified with the <code>CARGO_REGISTRY_TOKEN</code>
74+
environment variable. Tokens for other registries may be specified with
75+
environment variables of the form <code>CARGO_REGISTRIES_NAME_TOKEN</code> where <code>NAME</code>
76+
is the name of the registry in all capital letters.</p>
77+
</div>
7178
</dd>
7279
<dt class="hdlist1"><strong>--no-verify</strong></dt>
7380
<dd>
@@ -83,11 +90,9 @@ <h3 id="cargo_publish_publish_options">Publish Options</h3>
8390
</dd>
8491
<dt class="hdlist1"><strong>--registry</strong> <em>REGISTRY</em></dt>
8592
<dd>
86-
<p>Alternative registry to use.</p>
87-
<div class="paragraph">
88-
<p>This option is unstable and available only on the nightly channel and requires
89-
the <code>-Z unstable-options</code> flag to enable.</p>
90-
</div>
93+
<p>Name of the registry to use. Registry names are defined in <a href="reference/config.html">Cargo config files</a>.
94+
If not specified, the default registry is used, which is defined by the
95+
<code>registry.default</code> config key which defaults to <code>crates-io</code>.</p>
9196
</dd>
9297
</dl>
9398
</div>

0 commit comments

Comments
 (0)