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

Method display_dry_run

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

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

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