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

Function insert_single

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

`atomic insert ` over InsertChanges — the raw reference rides the single-ref arm (the handler resolves it with the local resolver's semantics); both --deps forms (the escape hatch rides apply_dependencies). Rendered with the local single-insert body's exact print functions.

(
    change: &str,
    view: Option<String>,
    allow_conflicts: bool,
    deps: bool,
)

Source from the content-addressed store, hash-verified

4029/// apply_dependencies). Rendered with the local single-insert body's
4030/// exact print functions.
4031pub fn insert_single(
4032 change: &str,
4033 view: Option<String>,
4034 allow_conflicts: bool,
4035 deps: bool,
4036) -> CliResult<bool> {
4037 let Some(session) = Service::open()? else {
4038 return Ok(false);
4039 };
4040 let request = insert_request(
4041 &session,
4042 Some(pb::insert_changes_request::Source::SingleRef(
4043 change.to_string(),
4044 )),
4045 view,
4046 allow_conflicts,
4047 deps,
4048 false,
4049 );
4050 let response = insert_rpc(&session, request)?;
4051 let hash = response
4052 .resolved_change
4053 .as_ref()
4054 .and_then(|h| h.value.clone().try_into().ok())
4055 .map(Merkle);
4056 if let Some(hash) = hash {
4057 print_info(&format!(
4058 "Inserting change {}...",
4059 crate::commands::format_hash(&hash, true)
4060 ));
4061 }
4062 let applied = insert_applied_hashes(&response);
4063 let new_state = response
4064 .new_state
4065 .as_ref()
4066 .and_then(|h| h.value.clone().try_into().ok())
4067 .map(Merkle)
4068 .unwrap_or_default();
4069 super::insert::print_insert_outcome(&applied, new_state, response.has_conflicts);
4070 print_insert_refresh(&response, false);
4071 Ok(true)
4072}
4073
4074/// `atomic insert view <source> [--to <target>] [-n]` over InsertChanges —
4075/// both --deps forms and the dry-run preview (the handler computes the

Callers 1

runMethod · 0.85

Calls 10

openFunction · 0.85
insert_requestFunction · 0.85
insert_rpcFunction · 0.85
print_infoFunction · 0.85
insert_applied_hashesFunction · 0.85
print_insert_outcomeFunction · 0.85
print_insert_refreshFunction · 0.85
as_refMethod · 0.80
okMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected