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

Function materialize_view

atomic-core/src/output/repo/repository/mod.rs:208–299  ·  view source on GitHub ↗

Materialize the repository view (or prefix) to the working copy. This is the main entry point for synchronizing the working copy with the repository graph state. It traverses the tree, outputs each file, and collects all conflicts.

(
    txn: &T,
    changes: &C,
    working_copy: &W,
    options: MaterializeOptions,
)

Source from the content-addressed store, hash-verified

206/// the repository graph state. It traverses the tree, outputs each file,
207/// and collects all conflicts.
208pub fn materialize_view<T, C, W>(
209 txn: &T,
210 changes: &C,
211 working_copy: &W,
212 options: MaterializeOptions,
213) -> Result<MaterializeResult, MaterializeError<W::Error>>
214where
215 T: TreeTxnT + GraphTxnT,
216 C: ChangeStore,
217 W: WorkingCopy,
218 W::Writer: std::io::Write,
219{
220 let mut result = MaterializeResult::new();
221
222 // Collect items to output starting from root
223 let items = collect_children(txn, Inode::ROOT, "", &options)?;
224
225 // Process each item
226 let file_options = options.to_file_options();
227
228 // ── View-aware pre-filter ──────────────────────────────────────
229 let (passing_file_paths, passing_ancestors) =
230 filter::compute_filters(&items, &options.change_filter);
231
232 for item in items {
233 if item.is_directory {
234 // Only create directories that will contain files on this view
235 if !filter::dir_has_passing_children(&item.path, &passing_ancestors) {
236 result.record_skipped();
237 continue;
238 }
239 // Selective materialize: skip directories with no target files.
240 if let Some(ref paths) = options.only_paths {
241 let has_target = paths.iter().any(|p| p.starts_with(&item.path));
242 if !has_target {
243 result.record_skipped();
244 continue;
245 }
246 }
247 // Create directory
248 working_copy
249 .create_dir_all(&item.path)
250 .map_err(MaterializeError::WorkingCopy)?;
251 result.record_directory();
252 } else {
253 // Check prefix filter
254 if !options.matches_prefix(&item.path) {
255 result.record_skipped();
256 continue;
257 }
258
259 // Selective materialize: skip files not in the explicit path set.
260 if let Some(ref paths) = options.only_paths {
261 if !paths.contains(&item.path) {
262 result.record_skipped();
263 continue;
264 }
265 }

Callers 4

materialize_prefixFunction · 0.85
materialize_prefixMethod · 0.85

Calls 13

collect_childrenFunction · 0.85
compute_filtersFunction · 0.85
dir_has_passing_childrenFunction · 0.85
output_file_with_filterFunction · 0.85
to_file_optionsMethod · 0.80
merge_file_resultMethod · 0.80
record_skippedMethod · 0.45
iterMethod · 0.45
create_dir_allMethod · 0.45
record_directoryMethod · 0.45
matches_prefixMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected