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

Method run

atomic-cli/src/commands/revise.rs:569–680  ·  view source on GitHub ↗

Execute the revise command. # Process 1. Parse and resolve the change reference 2. If dry-run, show what would happen and exit 3. Unrecord changes from target to top 4. Get new message (from arg, editor, or original) 5. Record the revised change 6. Re-apply subsequent changes

(&self)

Source from the content-addressed store, hash-verified

567 /// 5. Record the revised change
568 /// 6. Re-apply subsequent changes
569 fn run(&self) -> CliResult<()> {
570 // Route EVERY form through the service layer (BEFORE any local
571 // repository open): the reference resolves over the wire's Log,
572 // the message composes client-side (an explicit -m, or the SAME
573 // editor flow the local body runs, seeded with the change's
574 // current message fetched over the wire), the dry-run preview
575 // renders over the wire's log entries, and the stack surgery —
576 // reword or content re-capture — is the domain's, applied
577 // atomically by the handler.
578 if crate::commands::rpc::revise(self)? {
579 return Ok(());
580 }
581
582 // Find and open repository
583 let repo_root = find_repository_root()?;
584 let mode = if self.dry_run {
585 WorkspaceTxnMode::Observe
586 } else {
587 WorkspaceTxnMode::Reconcile
588 };
589 let mut repo = match mode {
590 WorkspaceTxnMode::Observe => Repository::open_readonly(&repo_root),
591 WorkspaceTxnMode::Reconcile => Repository::open_for_workspace_transaction(&repo_root),
592 WorkspaceTxnMode::Force => unreachable!("revise never forces workspace entry"),
593 }
594 .map_err(CliError::Repository)?;
595 let workspace = enter_workspace(&mut repo, mode)?;
596 let working_copy = workspace.working_copy();
597 let workspace_view = &workspace.view().name;
598
599 // Resolve the reference
600 let (sequence, entry) = self.resolve_reference(&repo, workspace_view)?;
601
602 // Dry run mode
603 if self.dry_run {
604 return self.display_dry_run(&repo, workspace_view, sequence, &entry);
605 }
606
607 // Reword mode: the whole stack surgery is the domain's (the same
608 // code path the daemon's Revise RPC calls). The message resolves
609 // client-side (arg, editor, or original); the author too.
610 if self.reword {
611 let original = repo
612 .load_change(&entry.hash)
613 .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load change: {}", e)))?;
614 let message = self.get_message(&original.hashed.header.message.clone())?;
615 let author = self
616 .parse_author()
617 .map(|(name, email)| atomic_core::change::Author {
618 name,
619 email,
620 identity: None,
621 });
622
623 let change_ref = self.parse_reference();
624 println!(
625 "Revising change {} (sequence #{})...",
626 change_ref.description(),

Callers

nothing calls this directly

Calls 15

reviseFunction · 0.85
find_repository_rootFunction · 0.85
print_successFunction · 0.85
print_hintFunction · 0.85
print_warningFunction · 0.85
resolve_referenceMethod · 0.80
parse_referenceMethod · 0.80
reword_changeMethod · 0.80
is_noneMethod · 0.80
execute_reviseMethod · 0.80
enter_workspaceFunction · 0.70
working_copyMethod · 0.45

Tested by

no test coverage detected