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

Method display_dry_run

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

Display what would be done in dry-run mode.

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

Source from the content-addressed store, hash-verified

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

Callers 1

runMethod · 0.45

Calls 4

current_viewMethod · 0.80
get_view_infoMethod · 0.80
logMethod · 0.80
into_iterMethod · 0.45

Tested by

no test coverage detected