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

Method write_import_recorded

atomic-repository/src/repository/insert.rs:726–916  ·  view source on GitHub ↗

Assemble, save, and apply a freshly imported Git commit without going through the normal `insert_change()` load/check path. This preserves the normal graph writer and CRDT table application, but avoids reloading the just-saved change and avoids the `has_change_in_graph` probe. The write transaction is opened before assembly, so globalization and application share one consistent transaction view.

(
        &self,
        header: ChangeHeader,
        recorded_files: &[atomic_core::record::workflow::RecordedFile],
        unhashed: serde_json::Value,
        deleted_paths: &[String],
        pr

Source from the content-addressed store, hash-verified

724 /// graph-only so importing into a foreign view cannot rewrite the active
725 /// view's global TREE mappings.
726 pub fn write_import_recorded(
727 &self,
728 header: ChangeHeader,
729 recorded_files: &[atomic_core::record::workflow::RecordedFile],
730 unhashed: serde_json::Value,
731 deleted_paths: &[String],
732 preserve_existing_tree_paths: bool,
733 options: InsertOptions,
734 ) -> Result<ImportWriteOutcome, RepositoryError> {
735 use atomic_core::record::workflow::assemble_change;
736 use atomic_core::record::workflow::assembly::AssemblyOptions;
737
738 let mut timings = ImportWriteTimings::default();
739 let view_name = options.view.as_deref().unwrap_or(&self.current_view);
740
741 let mut txn = self
742 .pristine
743 .write_txn()
744 .map_err(|e| RepositoryError::Database(e.to_string()))?;
745
746 let assemble_start = std::time::Instant::now();
747 let mut change = if recorded_files.is_empty() {
748 Change::empty(header)
749 } else {
750 match assemble_change(
751 &txn,
752 recorded_files,
753 header.clone(),
754 &AssemblyOptions::default(),
755 ) {
756 Ok(result) => result.into_change(),
757 Err(e) => {
758 let err_msg = e.to_string();
759 if err_msg.contains("empty") || err_msg.contains("AllEmpty") {
760 Change::empty(header)
761 } else {
762 return Err(RepositoryError::Apply(e.to_string()));
763 }
764 }
765 }
766 };
767 timings.assemble_ms = assemble_start.elapsed().as_millis();
768
769 change.unhashed = Some(unhashed);
770
771 let mut v3_bytes = Vec::new();
772 let hash = change
773 .serialize(&mut v3_bytes)
774 .map_err(|e| RepositoryError::Database(e.to_string()))?;
775 let (final_change, verified_hash) = Change::deserialize(&mut v3_bytes.as_slice())
776 .map_err(|e| RepositoryError::Database(e.to_string()))?;
777 debug_assert_eq!(hash, verified_hash);
778
779 let save_start = std::time::Instant::now();
780 self.save_change_bytes(&hash, &v3_bytes, &final_change)?;
781 timings.save_ms = save_start.elapsed().as_millis();
782
783 let change_id = txn

Callers 2

write_commitMethod · 0.80
write_empty_commitMethod · 0.80

Calls 15

assemble_changeFunction · 0.85
collect_tree_opsFunction · 0.85
explicit_emptyFunction · 0.85
is_file_only_on_viewFunction · 0.85
import_direct_can_applyFunction · 0.85
write_change_to_graphFunction · 0.85
write_txnMethod · 0.80
save_change_bytesMethod · 0.80
register_changeMethod · 0.80
put_change_depsMethod · 0.80
put_treeMethod · 0.80
put_inodeMethod · 0.80

Tested by

no test coverage detected