MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / restore

Function restore

atomic-cli/src/commands/rpc.rs:3720–3746  ·  view source on GitHub ↗

`atomic restore` over Restore. The non-dry-run forms route; every dry-run form routes through the PreviewRestore arm the command dispatches next — the listing form (no paths, or more than one) via `restore_preview`, the single-file pristine-bytes dump via `restore_single_dry_run` (the wire's content arm). The whole-copy refusal surfaces with the daemon's message.

(args: &super::restore::Restore)

Source from the content-addressed store, hash-verified

3718/// `restore_single_dry_run` (the wire's content arm). The whole-copy
3719/// refusal surfaces with the daemon's message.
3720pub fn restore(args: &super::restore::Restore) -> CliResult<bool> {
3721 if args.dry_run {
3722 return Ok(false);
3723 }
3724 let Some(session) = Service::open()? else {
3725 return Ok(false);
3726 };
3727 let request = pb::RestoreRequest {
3728 repository: Some(session.reference.clone()),
3729 meta: None,
3730 paths: args.files.clone(),
3731 force: args.force,
3732 };
3733 let response = session.restore(request)?;
3734
3735 if response.restored.is_empty() {
3736 println!("Nothing to restore - working copy is clean");
3737 return Ok(true);
3738 }
3739 println!("Restoring working copy...");
3740 for path in &response.restored {
3741 println!(" Restored: {path}");
3742 }
3743 println!();
3744 print_success(&format!("Restored {} file(s)", response.restored.len()));
3745 Ok(true)
3746}
3747
3748// ---------------------------------------------------------------------------
3749// stash (RepositoryMutationService)

Callers 2

runMethod · 0.85
test_line_ops_restoreFunction · 0.85

Calls 5

print_successFunction · 0.85
openFunction · 0.50
cloneMethod · 0.45
restoreMethod · 0.45
is_emptyMethod · 0.45

Tested by 1

test_line_ops_restoreFunction · 0.68