Phase 2: Write changes sequentially with hash chaining.
(
&self,
repo: &mut Repository,
commits: &[ParsedCommit],
line_index: &mut ImportLineIndex,
)
| 2569 | |
| 2570 | /// Phase 2: Write changes sequentially with hash chaining. |
| 2571 | fn phase2_write( |
| 2572 | &self, |
| 2573 | repo: &mut Repository, |
| 2574 | commits: &[ParsedCommit], |
| 2575 | line_index: &mut ImportLineIndex, |
| 2576 | ) -> CliResult<(WriteStats, Vec<ImportedCommitInfo>)> { |
| 2577 | let mut stats = WriteStats::default(); |
| 2578 | let mut imported_commits = Vec::new(); |
| 2579 | let total = commits.len(); |
| 2580 | let phase2_start = Instant::now(); |
| 2581 | let mut batch_start = Instant::now(); |
| 2582 | |
| 2583 | for (idx, parsed) in commits.iter().enumerate() { |
| 2584 | // Commits created by `atomic git push` whose referenced view |
| 2585 | // state is already present add nothing — skip them entirely. |
| 2586 | if should_skip_self_push(parsed, &self.options) { |
| 2587 | stats.self_push_skipped += 1; |
| 2588 | continue; |
| 2589 | } |
| 2590 | |
| 2591 | // Progress reporting with per-batch timing |
| 2592 | if total > 100 && idx % 100 == 0 { |
| 2593 | if idx == 0 { |
| 2594 | print_info(&format!(" Writing {}/{}...", idx, total)); |
| 2595 | } else { |
| 2596 | let batch_elapsed = batch_start.elapsed(); |
| 2597 | let total_elapsed = phase2_start.elapsed(); |
| 2598 | let avg_per_commit = total_elapsed.as_secs_f64() / idx as f64; |
| 2599 | print_info(&format!( |
| 2600 | " Writing {}/{}... (last 100: {:.2}s, avg: {:.1}ms/commit)", |
| 2601 | idx, |
| 2602 | total, |
| 2603 | batch_elapsed.as_secs_f64(), |
| 2604 | avg_per_commit * 1000.0, |
| 2605 | )); |
| 2606 | } |
| 2607 | batch_start = Instant::now(); |
| 2608 | } |
| 2609 | |
| 2610 | // Write the change |
| 2611 | match self.write_commit(repo, parsed, line_index) { |
| 2612 | Ok(info) => { |
| 2613 | if parsed.is_empty { |
| 2614 | stats.empty_commits += 1; |
| 2615 | } else if parsed.is_merge { |
| 2616 | stats.merge_commits += 1; |
| 2617 | } else { |
| 2618 | stats.changes_written += 1; |
| 2619 | } |
| 2620 | stats.files_processed += parsed.files.len(); |
| 2621 | imported_commits.push(info); |
| 2622 | } |
| 2623 | Err(e) => { |
| 2624 | print_warning(&format!("Failed to write {}: {}", parsed.short_sha, e)); |
| 2625 | } |
| 2626 | } |
| 2627 | } |
| 2628 |
no test coverage detected