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

Function unrecord

atomic-cli/src/commands/rpc.rs:3502–3534  ·  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

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

Callers 1

runMethod · 0.85

Calls 8

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

Tested by

no test coverage detected