Assemble a change from recorded files. This is the main entry point for creating a Change from recording results. It globalizes all hunks, collects dependencies, and creates the final Change structure. # Arguments `txn` - Transaction for graph lookups `files` - The recorded files to assemble `header` - The change header `options` - Assembly options # Returns The assembled change, or an error
(
txn: &T,
files: &[RecordedFile],
header: ChangeHeader,
options: &AssemblyOptions,
)
| 567 | /// let change = assemble_change(&txn, &recorded_files, header, &AssemblyOptions::default())?; |
| 568 | /// ``` |
| 569 | pub fn assemble_change<T>( |
| 570 | txn: &T, |
| 571 | files: &[RecordedFile], |
| 572 | header: ChangeHeader, |
| 573 | options: &AssemblyOptions, |
| 574 | ) -> types::AssemblyResult<AssemblyResult_> |
| 575 | where |
| 576 | T: GraphTxnT |
| 577 | + TreeTxnT |
| 578 | + CrdtTxnT |
| 579 | + crate::pristine::InodeAttrTxnT |
| 580 | + crate::pristine::InodeGraphOps, |
| 581 | { |
| 582 | // Validate input |
| 583 | if files.is_empty() { |
| 584 | return Err(types::AssemblyError::NoFiles); |
| 585 | } |
| 586 | |
| 587 | log::debug!("assemble_change: {} files", files.len(),); |
| 588 | |
| 589 | // Create globalization context. Closure-projected path bindings (see |
| 590 | // `ProjectedPathBinding`) are seeded first so parent-directory |
| 591 | // anchoring consults the assembly view's identity before the ambient |
| 592 | // TREE — required under a preserved (deferred-TREE) incremental import. |
| 593 | let mut glob_ctx = GlobalizeContext::new(txn); |
| 594 | glob_ctx.seed_projected_paths(options.get_globalize_options().projected_paths().clone()); |
| 595 | for file in files { |
| 596 | if let Some(inode) = file.inode() { |
| 597 | if let Some(old_path) = file.old_path() { |
| 598 | glob_ctx.vacate_binding(old_path, inode); |
| 599 | } else if matches!( |
| 600 | file.kind(), |
| 601 | Some(crate::record::workflow::DetectionKind::Deleted) |
| 602 | ) { |
| 603 | glob_ctx.vacate_binding(file.path(), inode); |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | let mut ctx = AssemblyContext::new(header); |
| 608 | let mut stats = AssemblyStats::new(); |
| 609 | let mut globalized_files = Vec::new(); |
| 610 | let globalize_errors = Vec::new(); |
| 611 | |
| 612 | // Process each file |
| 613 | let total_files = files.len(); |
| 614 | let assembly_start = Instant::now(); |
| 615 | |
| 616 | for (file_idx, file) in files.iter().enumerate() { |
| 617 | stats.record_file(); |
| 618 | |
| 619 | // Skip empty files if configured, but never skip directories |
| 620 | // (directories generate hunks during globalization, not during recording) |
| 621 | if file.is_empty() |
| 622 | && !options.get_include_empty_files() |
| 623 | && !file.is_directory() |
| 624 | && !file.is_deleted_directory() |
| 625 | { |
| 626 | log::debug!( |
no test coverage detected