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

Method display_dry_run

atomic-cli/src/commands/revise.rs:449–514  ·  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

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

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