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

Function unrecord

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

`atomic unrecord` over Unrecord — the non-dry-run forms, bare or with a change argument: the prefix rides the wire's ChangeRef prefix arm (whole-store resolution, the same resolver the local body uses; the membership/dependency refusals surface from the handler). `--dry-run` declines here and routes through the PreviewMutation arm the command dispatches next.

(args: &super::unrecord::Unrecord)

Source from the content-addressed store, hash-verified

3501/// `--dry-run` declines here and routes through the PreviewMutation arm
3502/// the command dispatches next.
3503pub fn unrecord(args: &super::unrecord::Unrecord) -> CliResult<bool> {
3504 if args.dry_run {
3505 return Ok(false); // the preview rides unrecord_preview below
3506 }
3507 let Some(session) = Service::open()? else {
3508 return Ok(false);
3509 };
3510
3511 // A bare hash prefix needs the full 32-byte hash before the wire call:
3512 // resolve it through the service layer (a read, no redb here).
3513 let target = args.change.as_ref().map(|prefix| pb::ChangeRef {
3514 kind: Some(pb::change_ref::Kind::Prefix(prefix.clone())),
3515 });
3516 let request = pb::UnrecordRequest {
3517 repository: Some(session.reference.clone()),
3518 meta: None,
3519 expected: None,
3520 view: None,
3521 target,
3522 };
3523 let response = session.unrecord(request)?;
3524
3525 if let Some(change) = &response.removed {
3526 let hash = change
3527 .hash
3528 .as_ref()
3529 .and_then(|h| h.value.clone().try_into().ok())
3530 .map(|bytes: [u8; 32]| Merkle(bytes).to_base32())
3531 .unwrap_or_else(|| "-".to_string());
3532 print_success(&format!("Unrecorded: {hash}"));
3533 }
3534 Ok(true)
3535}
3536
3537// ---------------------------------------------------------------------------
3538// view mutations (ViewService)

Callers 1

runMethod · 0.85

Calls 8

MerkleClass · 0.85
print_successFunction · 0.85
as_refMethod · 0.80
openFunction · 0.50
cloneMethod · 0.45
unrecordMethod · 0.45
okMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected