Skip to content

Commit e023a66

Browse files
committed
Add install-upgrade.
1 parent 6bdb9d3 commit e023a66

File tree

12 files changed

+1651
-413
lines changed

12 files changed

+1651
-413
lines changed

src/bin/cargo/cli.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Available unstable (nightly-only) flags:
3535
-Z offline -- Offline mode that does not perform network requests
3636
-Z unstable-options -- Allow the usage of unstable options such as --registry
3737
-Z config-profile -- Read profiles from .cargo/config files
38+
-Z install-upgrade -- `cargo install` will upgrade instead of failing
3839
3940
Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
4041
);

src/bin/cargo/commands/install.rs

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub fn cli() -> App {
4646
))
4747
.arg_jobs()
4848
.arg(opt("force", "Force overwriting existing crates or binaries").short("f"))
49+
.arg(opt(
50+
"no-track",
51+
"Do not save tracking information (unstable)",
52+
))
4953
.arg_features()
5054
.arg(opt("debug", "Build in debug mode instead of release mode"))
5155
.arg_targets_bins_examples(
@@ -148,6 +152,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
148152
let version = args.value_of("version");
149153
let root = args.value_of("root");
150154

155+
if args.is_present("no-track") && !config.cli_unstable().install_upgrade {
156+
Err(failure::format_err!(
157+
"`--no-track` flag is unstable, pass `-Z install-upgrade` to enable it"
158+
))?;
159+
};
160+
151161
if args.is_present("list") {
152162
ops::install_list(root, config)?;
153163
} else {
@@ -159,6 +169,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
159169
version,
160170
&compile_opts,
161171
args.is_present("force"),
172+
args.is_present("no-track"),
162173
)?;
163174
}
164175
Ok(())

src/cargo/core/features.rs

+2
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ pub struct CliUnstable {
328328
pub config_profile: bool,
329329
pub dual_proc_macros: bool,
330330
pub mtime_on_use: bool,
331+
pub install_upgrade: bool,
331332
}
332333

333334
impl CliUnstable {
@@ -372,6 +373,7 @@ impl CliUnstable {
372373
"config-profile" => self.config_profile = true,
373374
"dual-proc-macros" => self.dual_proc_macros = true,
374375
"mtime-on-use" => self.mtime_on_use = true,
376+
"install-upgrade" => self.install_upgrade = true,
375377
_ => failure::bail!("unknown `-Z` flag specified: {}", k),
376378
}
377379

0 commit comments

Comments
 (0)