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

Function revise

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

`atomic revise` over Revise — every form. The reference (@/@~N/hash prefix) resolves through the daemon's Log exactly as the local `resolve_reference` does (newest-first: "@" is the last change, "@~N" N back, a prefix case-insensitively with an ambiguity refusal). The message composes client-side — an explicit `-m`, or the SAME editor flow the local body runs, seeded with the change's current mess

(args: &super::revise::Revise)

Source from the content-addressed store, hash-verified

4494/// `--dry-run` renders the same preview the local body prints, over the
4495/// wire's log entries.
4496pub fn revise(args: &super::revise::Revise) -> CliResult<bool> {
4497 let Some(session) = Service::open()? else {
4498 return Ok(false);
4499 };
4500
4501 // Resolve the reference through the daemon's Log (newest first) to
4502 // the full hash plus the change's current message — the editor's
4503 // seed — and its sequence.
4504 let parsed = super::revise::ChangeRef::parse(&args.reference);
4505 let entries = log_entries(&session, "")?;
4506 let target = match &parsed {
4507 super::revise::ChangeRef::Last => {
4508 if entries.is_empty() {
4509 return Err(CliError::Internal(anyhow::anyhow!(
4510 "Cannot revise: view '{}' is empty",
4511 current_view_name()?
4512 )));
4513 }
4514 entries.first().cloned()
4515 }
4516 super::revise::ChangeRef::Relative(offset) => {
4517 let offset = *offset as usize;
4518 match entries.get(offset) {
4519 Some(entry) => Some(entry.clone()),
4520 None => {
4521 return Err(CliError::Internal(anyhow::anyhow!(
4522 "Reference @~{} is out of range (view has {} changes)",
4523 offset,
4524 entries.len()
4525 )))
4526 }
4527 }
4528 }
4529 super::revise::ChangeRef::Hash(prefix) => {
4530 let prefix_lower = prefix.to_lowercase();
4531 let matches: Vec<_> = entries
4532 .iter()
4533 .filter(|e| {
4534 e.hash
4535 .as_ref()
4536 .and_then(|h| h.value.clone().try_into().ok())
4537 .map(|bytes: [u8; 32]| {
4538 Merkle(bytes)
4539 .to_base32()
4540 .to_lowercase()
4541 .starts_with(&prefix_lower)
4542 })
4543 .unwrap_or(false)
4544 })
4545 .collect();
4546 match matches.as_slice() {
4547 [] => {
4548 return Err(CliError::ChangeNotFound {
4549 hash: prefix.to_string(),
4550 })
4551 }
4552 [single] => Some((*single).clone()),
4553 _ => {

Callers 1

runMethod · 0.85

Calls 15

log_entriesFunction · 0.85
MerkleClass · 0.85
print_warningFunction · 0.85
print_hintFunction · 0.85
print_successFunction · 0.85
as_refMethod · 0.80
is_noneMethod · 0.80
getMethod · 0.65
openFunction · 0.50
parseFunction · 0.50
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected