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

Method display_dry_run

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

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

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