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

Method display_dry_run

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

Display what would be done in dry-run mode.

(
        &self,
        repo: &Repository,
        workspace_view: &str,
        sequence: u64,
        entry: &HistoryEntry,
    )

Source from the content-addressed store, hash-verified

459
460 /// Display what would be done in dry-run mode.
461 fn display_dry_run(
462 &self,
463 repo: &Repository,
464 workspace_view: &str,
465 sequence: u64,
466 entry: &HistoryEntry,
467 ) -> CliResult<()> {
468 let stack_info = repo
469 .get_view_info(workspace_view)
470 .map_err(CliError::Repository)?;
471 let changes_to_unrecord = stack_info.change_count - sequence;
472
473 println!(
474 "Would revise change {} (sequence #{})",
475 format_hash(&entry.hash, false),
476 sequence
477 );
478 println!();
479
480 if changes_to_unrecord > 1 {
481 println!(
482 "This will temporarily unrecord {} changes:",
483 changes_to_unrecord
484 );
485
486 // Get history entries for display
487 let history = repo
488 .log(HistoryOptions::default().view(workspace_view))
489 .map_err(CliError::Repository)?;
490
491 // Filter and display entries from sequence to end (in reverse order)
492 let mut entries_to_show: Vec<_> = history
493 .into_iter()
494 .filter(|e| e.sequence >= sequence)
495 .collect();
496 entries_to_show.sort_by_key(|x| std::cmp::Reverse(x.sequence));
497
498 for e in entries_to_show {
499 let marker = if e.sequence == sequence {
500 " (target)"
501 } else {
502 ""
503 };
504 println!(
505 " #{}: {}{}",
506 e.sequence,
507 format_hash(&e.hash, false),
508 marker
509 );
510 }
511 println!();
512 println!(
513 "After revision, {} changes will be re-applied.",
514 changes_to_unrecord - 1
515 );
516 } else {
517 println!("This is the last change - no re-application needed.");
518 }

Callers 1

runMethod · 0.45

Calls 5

get_view_infoMethod · 0.80
logMethod · 0.45
viewMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected