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

Method phase2_write

atomic-cli/src/commands/git/parallel.rs:2642–2758  ·  view source on GitHub ↗

Phase 2: Write changes sequentially with hash chaining.

(
        &self,
        repo: &mut Repository,
        commits: &[ParsedCommit],
        line_index: &mut ImportLineIndex,
    )

Source from the content-addressed store, hash-verified

2640
2641 /// Phase 2: Write changes sequentially with hash chaining.
2642 fn phase2_write(
2643 &self,
2644 repo: &mut Repository,
2645 commits: &[ParsedCommit],
2646 line_index: &mut ImportLineIndex,
2647 ) -> CliResult<(WriteStats, Vec<ImportedCommitInfo>)> {
2648 let mut stats = WriteStats::default();
2649 let mut imported_commits = Vec::new();
2650 let total = commits.len();
2651 let phase2_start = Instant::now();
2652 let mut batch_start = Instant::now();
2653
2654 for (idx, parsed) in commits.iter().enumerate() {
2655 // Commits created by `atomic git push` whose referenced view
2656 // state is already present add nothing — skip them entirely.
2657 if should_skip_self_push(parsed, &self.options) {
2658 stats.self_push_skipped += 1;
2659 continue;
2660 }
2661
2662 // Squash → insert (SPEC §4): an atomic-origin squash-merge is
2663 // represented by inserting its original change records into the
2664 // target view, not by writing a new squash change. Only attempted
2665 // on incremental imports (the git-shadow-sync workflow), where the
2666 // originals already exist in the graph.
2667 if self.options.incremental {
2668 match self.try_squash_insert(repo, parsed)? {
2669 SquashDecision::Inserted(info) => {
2670 stats.squash_inserted += 1;
2671 stats.files_processed += parsed.files.len();
2672 imported_commits.push(info);
2673 continue;
2674 }
2675 SquashDecision::Skipped => {
2676 stats.squash_skipped += 1;
2677 continue;
2678 }
2679 SquashDecision::NotSquash => {}
2680 }
2681 }
2682
2683 // Progress reporting with per-batch timing
2684 if total > 100 && idx % 100 == 0 {
2685 if idx == 0 {
2686 print_info(&format!(" Writing {}/{}...", idx, total));
2687 } else {
2688 let batch_elapsed = batch_start.elapsed();
2689 let total_elapsed = phase2_start.elapsed();
2690 let avg_per_commit = total_elapsed.as_secs_f64() / idx as f64;
2691 print_info(&format!(
2692 " Writing {}/{}... (last 100: {:.2}s, avg: {:.1}ms/commit)",
2693 idx,
2694 total,
2695 batch_elapsed.as_secs_f64(),
2696 avg_per_commit * 1000.0,
2697 ));
2698 }
2699 batch_start = Instant::now();

Callers 1

import_branchMethod · 0.80

Calls 13

should_skip_self_pushFunction · 0.85
print_infoFunction · 0.85
try_squash_insertMethod · 0.80
write_commitMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
rootMethod · 0.45
modifiedMethod · 0.45
replaceMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected