(
&self,
outcome: &RecordOutcome,
mut options: InsertOptions,
removal: Option<(&str, Hash)>,
)
| 3050 | } |
| 3051 | |
| 3052 | pub(super) fn write_recorded_replacing( |
| 3053 | &self, |
| 3054 | outcome: &RecordOutcome, |
| 3055 | mut options: InsertOptions, |
| 3056 | removal: Option<(&str, Hash)>, |
| 3057 | ) -> Result<InsertOutcome, RepositoryError> { |
| 3058 | if self.is_remote_sandbox() { |
| 3059 | return self.submit_recorded(outcome); |
| 3060 | } |
| 3061 | let trace_record = std::env::var_os("ATOMIC_TRACE_RECORD").is_some(); |
| 3062 | let change = outcome.change(); |
| 3063 | let hash = outcome.hash(); |
| 3064 | |
| 3065 | // A freshly-recorded change is applied to the view it was recorded on. |
| 3066 | // Its dependency closure is complete by construction, so it cannot |
| 3067 | // produce zombie or missing-context conflicts. Disable conflict |
| 3068 | // detection to skip the per-hunk zombie/deleted-context graph scans |
| 3069 | // (the dominant apply cost on large changes); the graph written is |
| 3070 | // identical, only the (empty) conflict report is skipped. |
| 3071 | options.track_conflicts = false; |
| 3072 | |
| 3073 | // Get write transaction |
| 3074 | let mut txn = self |
| 3075 | .pristine |
| 3076 | .write_txn() |
| 3077 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3078 | |
| 3079 | let view_name = options.view.as_deref().unwrap_or(&self.current_view); |
| 3080 | self.ensure_change_allowed_in_view(&txn, view_name, change)?; |
| 3081 | |
| 3082 | // Register the change to get an internal ID |
| 3083 | let change_id = txn |
| 3084 | .register_change(hash) |
| 3085 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3086 | txn.put_change_deps(change_id, change.dependencies()) |
| 3087 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3088 | |
| 3089 | // Determine which view to use |
| 3090 | let preserve_existing_tree_paths = view_name != self.current_view; |
| 3091 | let tree_projection = self.plan_tree_projection( |
| 3092 | &mut txn, |
| 3093 | change_id, |
| 3094 | *hash, |
| 3095 | change, |
| 3096 | outcome.deleted_files(), |
| 3097 | preserve_existing_tree_paths, |
| 3098 | )?; |
| 3099 | tree_projection.apply_prerequisites(&mut txn)?; |
| 3100 | // Apply to the graph |
| 3101 | // For write_recorded, the change is always new (just recorded), so |
| 3102 | // already_in_graph is always false. |
| 3103 | let mut apply_outcome = write_recorded_graph_and_spans( |
| 3104 | self, &mut txn, view_name, change_id, hash, change, &options, |
| 3105 | )?; |
| 3106 | |
| 3107 | if let Some((removal_view_name, removed_hash)) = removal { |
| 3108 | let mut removal_view = txn |
| 3109 | .get_view(removal_view_name) |
no test coverage detected