Save and apply an already-built git-import graph change. This bypasses record/globalize and eager CRDT table writes. The caller has already compiled Git's snapshot delta into line-level graph ops. `preserve_existing_tree_paths` keeps deletions and renames graph-only while a different view owns the materialized working copy.
(
&self,
change: Change,
deleted_paths: &[String],
preserve_existing_tree_paths: bool,
options: InsertOptions,
)
| 922 | /// `preserve_existing_tree_paths` keeps deletions and renames graph-only |
| 923 | /// while a different view owns the materialized working copy. |
| 924 | pub fn write_import_graph_change( |
| 925 | &self, |
| 926 | change: Change, |
| 927 | deleted_paths: &[String], |
| 928 | preserve_existing_tree_paths: bool, |
| 929 | options: InsertOptions, |
| 930 | ) -> Result<ImportWriteOutcome, RepositoryError> { |
| 931 | let mut timings = ImportWriteTimings::default(); |
| 932 | let view_name = options.view.as_deref().unwrap_or(&self.current_view); |
| 933 | |
| 934 | let mut txn = self |
| 935 | .pristine |
| 936 | .write_txn() |
| 937 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 938 | |
| 939 | let assemble_start = std::time::Instant::now(); |
| 940 | let mut v3_bytes = Vec::new(); |
| 941 | let hash = change |
| 942 | .serialize(&mut v3_bytes) |
| 943 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 944 | let (final_change, verified_hash) = Change::deserialize(&mut v3_bytes.as_slice()) |
| 945 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 946 | debug_assert_eq!(hash, verified_hash); |
| 947 | timings.assemble_ms = assemble_start.elapsed().as_millis(); |
| 948 | |
| 949 | let save_start = std::time::Instant::now(); |
| 950 | self.save_change_bytes(&hash, &v3_bytes, &final_change)?; |
| 951 | timings.save_ms = save_start.elapsed().as_millis(); |
| 952 | |
| 953 | let change_id = txn |
| 954 | .register_change(&hash) |
| 955 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 956 | txn.put_change_deps(change_id, final_change.dependencies()) |
| 957 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 958 | |
| 959 | let tree_ops = collect_tree_ops(&txn, hash, &final_change, deleted_paths)?; |
| 960 | |
| 961 | let apply_start = std::time::Instant::now(); |
| 962 | let insert = if import_graph_first_can_apply(&final_change) { |
| 963 | let (insert, graph_ms, crdt_ms) = self.write_import_graph_first_direct( |
| 964 | &mut txn, |
| 965 | view_name, |
| 966 | change_id, |
| 967 | &hash, |
| 968 | &final_change, |
| 969 | preserve_existing_tree_paths, |
| 970 | )?; |
| 971 | timings.direct_graph_ms = graph_ms; |
| 972 | timings.direct_crdt_ms = crdt_ms; |
| 973 | insert |
| 974 | } else { |
| 975 | write_change_to_graph( |
| 976 | &mut txn, |
| 977 | view_name, |
| 978 | change_id, |
| 979 | &hash, |
| 980 | &final_change, |
| 981 | &options, |
no test coverage detected