Import commits from a branch into an Atomic repository. Commits are processed in **batches** to keep memory bounded and show progress sooner. Each batch: parse in parallel → write sequentially. Imports use a fixed 1,000-commit batch size. This keeps progress and memory behavior predictable across small and large repositories.
(
&self,
branch_name: &str,
repo: &mut Repository,
)
| 2147 | /// Imports use a fixed 1,000-commit batch size. This keeps progress and |
| 2148 | /// memory behavior predictable across small and large repositories. |
| 2149 | pub fn import_branch( |
| 2150 | &self, |
| 2151 | branch_name: &str, |
| 2152 | repo: &mut Repository, |
| 2153 | ) -> CliResult<ImportStats> { |
| 2154 | let mut stats = ImportStats::default(); |
| 2155 | |
| 2156 | // Open git repo for this thread |
| 2157 | let git_repo = self.open_git_repo()?; |
| 2158 | |
| 2159 | // Collect commit OIDs in topological order |
| 2160 | let commit_oids = self.collect_commit_oids(&git_repo, branch_name)?; |
| 2161 | stats.commits_found = commit_oids.len(); |
| 2162 | |
| 2163 | if commit_oids.is_empty() { |
| 2164 | return Ok(stats); |
| 2165 | } |
| 2166 | |
| 2167 | let total = commit_oids.len(); |
| 2168 | let batch_size = Self::batch_size_for(total); |
| 2169 | |
| 2170 | print_info(&format!( |
| 2171 | "Importing {} commits in batches of {}...", |
| 2172 | total, batch_size |
| 2173 | )); |
| 2174 | |
| 2175 | let import_start = Instant::now(); |
| 2176 | let mut commits_written = 0usize; |
| 2177 | let mut line_index = ImportLineIndex::default(); |
| 2178 | let mut all_imported_commits: Vec<ImportedCommitInfo> = Vec::new(); |
| 2179 | |
| 2180 | for (batch_idx, chunk) in commit_oids.chunks(batch_size).enumerate() { |
| 2181 | let batch_start = batch_idx * batch_size; |
| 2182 | let batch_end = (batch_start + chunk.len()).min(total); |
| 2183 | |
| 2184 | print_info(&format!( |
| 2185 | "Batch {}: parsing commits {}-{} of {}...", |
| 2186 | batch_idx + 1, |
| 2187 | batch_start, |
| 2188 | batch_end, |
| 2189 | total |
| 2190 | )); |
| 2191 | |
| 2192 | // Phase 1: Parallel git parsing for this batch |
| 2193 | let parse_start = Instant::now(); |
| 2194 | let parsed_commits = self.phase1_parse(chunk)?; |
| 2195 | let parse_elapsed = parse_start.elapsed(); |
| 2196 | |
| 2197 | stats.phase1_duration += parse_elapsed; |
| 2198 | stats.commits_parsed += parsed_commits.len(); |
| 2199 | |
| 2200 | if parsed_commits.is_empty() { |
| 2201 | continue; |
| 2202 | } |
| 2203 | |
| 2204 | // Phase 2: Sequential write for this batch |
| 2205 | let write_start = Instant::now(); |
| 2206 | let (write_stats, batch_imported) = |
nothing calls this directly
no test coverage detected