Skip to content

Commit b902398

Browse files
committed
Add a dry_run argument to resolve_ws().
1 parent b95fb6e commit b902398

File tree

14 files changed

+48
-18
lines changed

14 files changed

+48
-18
lines changed

benches/benchsuite/benches/resolve.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn do_resolve<'gctx>(gctx: &'gctx GlobalContext, ws_root: &Path) -> ResolveInfo<
3333
let force_all_targets = ForceAllTargets::No;
3434
// Do an initial run to download anything necessary so that it does
3535
// not confuse criterion's warmup.
36+
let dry_run = false;
3637
let ws_resolve = cargo::ops::resolve_ws_with_opts(
3738
&ws,
3839
&mut target_data,
@@ -41,6 +42,7 @@ fn do_resolve<'gctx>(gctx: &'gctx GlobalContext, ws_root: &Path) -> ResolveInfo<
4142
&specs,
4243
has_dev_units,
4344
force_all_targets,
45+
dry_run,
4446
)
4547
.unwrap();
4648
ResolveInfo {
@@ -71,6 +73,7 @@ fn resolve_ws(c: &mut Criterion) {
7173
// iterator once, and we don't want to call `do_resolve` in every
7274
// "step", since that would just be some useless work.
7375
let mut lazy_info = None;
76+
let dry_run = false;
7477
group.bench_function(&ws_name, |b| {
7578
let ResolveInfo {
7679
ws,
@@ -91,6 +94,7 @@ fn resolve_ws(c: &mut Criterion) {
9194
specs,
9295
*has_dev_units,
9396
*force_all_targets,
97+
dry_run,
9498
)
9599
.unwrap();
96100
})

src/bin/cargo/commands/add.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,9 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
214214
};
215215
add(&ws, &options)?;
216216

217-
if !dry_run {
218-
// Reload the workspace since we've changed dependencies
219-
let ws = args.workspace(gctx)?;
220-
resolve_ws(&ws)?;
221-
}
217+
// Reload the workspace since we've changed dependencies
218+
let ws = args.workspace(gctx)?;
219+
resolve_ws(&ws, dry_run)?;
222220

223221
Ok(())
224222
}

src/bin/cargo/commands/remove.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
121121
ws.gctx()
122122
.shell()
123123
.set_verbosity(cargo::core::Verbosity::Quiet);
124-
let resolve = resolve_ws(&ws);
124+
let resolve = resolve_ws(&ws, dry_run);
125125
ws.gctx().shell().set_verbosity(verbosity);
126126
resolve?.1
127127
};
128128

129129
// Attempt to gc unused patches and re-resolve if anything is removed
130130
if gc_unused_patches(&workspace, &resolve)? {
131131
let ws = args.workspace(gctx)?;
132-
resolve_ws(&ws)?;
132+
resolve_ws(&ws, dry_run)?;
133133
}
134134
}
135135
Ok(())

src/cargo/core/compiler/standard_lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pub fn resolve_std<'gctx>(
149149
let cli_features = CliFeatures::from_command_line(
150150
&features, /*all_features*/ false, /*uses_default_features*/ false,
151151
)?;
152+
let dry_run = false;
152153
let resolve = ops::resolve_ws_with_opts(
153154
&std_ws,
154155
target_data,
@@ -157,6 +158,7 @@ pub fn resolve_std<'gctx>(
157158
&specs,
158159
HasDevUnits::No,
159160
crate::core::resolver::features::ForceAllTargets::No,
161+
dry_run,
160162
)?;
161163
Ok((
162164
resolve.pkg_set,

src/cargo/ops/cargo_clean.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> {
7777
if opts.spec.is_empty() {
7878
clean_ctx.remove_paths(&[target_dir.into_path_unlocked()])?;
7979
} else {
80-
clean_specs(&mut clean_ctx, &ws, &profiles, &opts.targets, &opts.spec)?;
80+
clean_specs(
81+
&mut clean_ctx,
82+
&ws,
83+
&profiles,
84+
&opts.targets,
85+
&opts.spec,
86+
opts.dry_run,
87+
)?;
8188
}
8289
}
8390

@@ -91,11 +98,12 @@ fn clean_specs(
9198
profiles: &Profiles,
9299
targets: &[String],
93100
spec: &[String],
101+
dry_run: bool,
94102
) -> CargoResult<()> {
95103
// Clean specific packages.
96104
let requested_kinds = CompileKind::from_requested_targets(clean_ctx.gctx, targets)?;
97105
let target_data = RustcTargetData::new(ws, &requested_kinds)?;
98-
let (pkg_set, resolve) = ops::resolve_ws(ws)?;
106+
let (pkg_set, resolve) = ops::resolve_ws(ws, dry_run)?;
99107
let prof_dir_name = profiles.get_dir_name();
100108
let host_layout = Layout::new(ws, None, &prof_dir_name)?;
101109
// Convert requested kinds to a Vec of layouts.

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ pub fn create_bcx<'a, 'gctx>(
264264
HasDevUnits::No
265265
}
266266
};
267+
let dry_run = false;
267268
let resolve = ops::resolve_ws_with_opts(
268269
ws,
269270
&mut target_data,
@@ -272,6 +273,7 @@ pub fn create_bcx<'a, 'gctx>(
272273
&specs,
273274
has_dev_units,
274275
crate::core::resolver::features::ForceAllTargets::No,
276+
dry_run,
275277
)?;
276278
let WorkspaceResolve {
277279
mut pkg_set,

src/cargo/ops/cargo_fetch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ pub fn fetch<'a>(
1919
options: &FetchOptions<'a>,
2020
) -> CargoResult<(Resolve, PackageSet<'a>)> {
2121
ws.emit_warnings()?;
22-
let (mut packages, resolve) = ops::resolve_ws(ws)?;
22+
let dry_run = false;
23+
let (mut packages, resolve) = ops::resolve_ws(ws, dry_run)?;
2324

2425
let jobs = Some(JobsConfig::Integer(1));
2526
let keep_going = false;

src/cargo/ops/cargo_install.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,8 @@ impl<'gctx> InstallablePackage<'gctx> {
561561
// It would be best if `source` could be passed in here to avoid a
562562
// duplicate "Updating", but since `source` is taken by value, then it
563563
// wouldn't be available for `compile_ws`.
564-
let (pkg_set, resolve) = ops::resolve_ws(&self.ws)?;
564+
let dry_run = false;
565+
let (pkg_set, resolve) = ops::resolve_ws(&self.ws, dry_run)?;
565566
ops::check_yanked(
566567
self.ws.gctx(),
567568
&pkg_set,

src/cargo/ops/cargo_output_metadata.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ fn build_resolve_graph(
142142

143143
// Note that even with --filter-platform we end up downloading host dependencies as well,
144144
// as that is the behavior of download_accessible.
145+
let dry_run = false;
145146
let ws_resolve = ops::resolve_ws_with_opts(
146147
ws,
147148
&mut target_data,
@@ -150,6 +151,7 @@ fn build_resolve_graph(
150151
&specs,
151152
HasDevUnits::Yes,
152153
force_all,
154+
dry_run,
153155
)?;
154156

155157
let package_map: BTreeMap<PackageId, Package> = ws_resolve

src/cargo/ops/cargo_package.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult<Option
190190

191191
if ws.root().join("Cargo.lock").exists() {
192192
// Make sure the Cargo.lock is up-to-date and valid.
193-
let _ = ops::resolve_ws(ws)?;
193+
let dry_run = false;
194+
let _ = ops::resolve_ws(ws, dry_run)?;
194195
// If Cargo.lock does not exist, it will be generated by `build_lock`
195196
// below, and will be validated during the verification step.
196197
}

0 commit comments

Comments
 (0)