Promote the current view's changes into its parent view. This is the behavior of a bare `atomic insert` (no change hash and no subcommand). The source is always the current view; the target defaults to the current view's parent but can be overridden with `--to`/`--view`. The working copy is intentionally NOT rematerialized: the target view is not checked out, so the current view's on-disk state
(repo: &Repository, workspace_view: &str, args: &Insert)
| 372 | /// The working copy is intentionally NOT rematerialized: the target view is |
| 373 | /// not checked out, so the current view's on-disk state is unchanged. |
| 374 | fn run_promote_to_parent(repo: &Repository, workspace_view: &str, args: &Insert) -> CliResult<()> { |
| 375 | let source = workspace_view.to_string(); |
| 376 | let source_info = repo |
| 377 | .get_view_info(&source) |
| 378 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 379 | |
| 380 | // Resolve the target: explicit --to/--view, else the current view's parent. |
| 381 | let target = match args.view.as_deref() { |
| 382 | Some(v) => v.to_string(), |
| 383 | None => source_info |
| 384 | .parent_name |
| 385 | .clone() |
| 386 | .ok_or_else(|| CliError::InvalidArgument { |
| 387 | message: format!( |
| 388 | "'{source}' is a root view — there is no parent to insert into.\n \ |
| 389 | Use 'atomic insert from-view <source>' or pass --to <view> \ |
| 390 | to choose a target." |
| 391 | ), |
| 392 | })?, |
| 393 | }; |
| 394 | |
| 395 | if target == source { |
| 396 | return Err(CliError::InvalidArgument { |
| 397 | message: format!( |
| 398 | "Source and target are the same view ('{source}'). \ |
| 399 | Pass --to <view> to insert somewhere else." |
| 400 | ), |
| 401 | }); |
| 402 | } |
| 403 | |
| 404 | // Figure out what would move so we can show a count and short-circuit. |
| 405 | let missing = repo |
| 406 | .get_missing_changes_between(&source, Some(&target)) |
| 407 | .map_err(|e| CliError::Conflict { |
| 408 | description: e.to_string(), |
| 409 | })?; |
| 410 | |
| 411 | if missing.is_empty() { |
| 412 | output::print_success(&format!( |
| 413 | "Already even with '{target}' — nothing to insert." |
| 414 | )); |
| 415 | return Ok(()); |
| 416 | } |
| 417 | |
| 418 | output::print_info(&format!( |
| 419 | "Inserting {} change(s): {source} → {target}", |
| 420 | missing.len() |
| 421 | )); |
| 422 | |
| 423 | // Dry run: list the changes and stop before mutating. |
| 424 | if args.dry_run { |
| 425 | let preview = repo |
| 426 | .insert_from_view( |
| 427 | CrossViewInsertOptions::new(&source, &target) |
| 428 | .with_dependencies(args.deps) |
| 429 | .dry_run(true), |
| 430 | ) |
| 431 | .map_err(CliError::Repository)?; |
no test coverage detected