Align the view pointer without materializing the working copy. This persists the new view name to `.atomic/current_view` so that subsequent `status()`, `add()`, and `record()` calls target the correct view, but it does **not** add, remove, or update any files on disk. Use this only when the caller will immediately populate the working copy itself (e.g. the agent record hook, which creates files
(
&mut self,
working_copy: WorkingCopyId,
view: &str,
)
| 1281 | /// Returns an error if the view does not exist or the pointer file |
| 1282 | /// cannot be written. |
| 1283 | pub fn align_to_view( |
| 1284 | &mut self, |
| 1285 | working_copy: WorkingCopyId, |
| 1286 | view: &str, |
| 1287 | ) -> Result<(), RepositoryError> { |
| 1288 | let operation_lock = self.try_lock_operation(working_copy)?; |
| 1289 | self.recover_pending_deferred_tree_alignment_locked(&operation_lock)?; |
| 1290 | let (record, target_view) = { |
| 1291 | let txn = self |
| 1292 | .pristine |
| 1293 | .read_txn() |
| 1294 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1295 | let record = txn |
| 1296 | .get_working_copy(working_copy) |
| 1297 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1298 | .ok_or(RepositoryError::WorkingCopyRecordNotFound { id: working_copy })?; |
| 1299 | let target_view = txn |
| 1300 | .get_view(view) |
| 1301 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1302 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 1303 | name: view.to_string(), |
| 1304 | })?; |
| 1305 | (record, target_view) |
| 1306 | }; |
| 1307 | let mut target = operation::working_copy_state_ref(record); |
| 1308 | target.desired_view = target_view.id; |
| 1309 | target.desired_state = target_view.state; |
| 1310 | target.materialized_state = None; |
| 1311 | target.materialized_manifest = None; |
| 1312 | self.apply_working_copy_state_locked(&operation_lock, &target) |
| 1313 | } |
| 1314 | |
| 1315 | /// Set the current view on this handle only. |
| 1316 | /// |