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,
)
| 1268 | /// Returns an error if the view does not exist or the pointer file |
| 1269 | /// cannot be written. |
| 1270 | pub fn align_to_view( |
| 1271 | &mut self, |
| 1272 | working_copy: WorkingCopyId, |
| 1273 | view: &str, |
| 1274 | ) -> Result<(), RepositoryError> { |
| 1275 | let operation_lock = self.try_lock_operation(working_copy)?; |
| 1276 | self.recover_pending_deferred_tree_alignment_locked(&operation_lock)?; |
| 1277 | let (record, target_view) = { |
| 1278 | let txn = self |
| 1279 | .pristine |
| 1280 | .read_txn() |
| 1281 | .map_err(|error| RepositoryError::Database(error.to_string()))?; |
| 1282 | let record = txn |
| 1283 | .get_working_copy(working_copy) |
| 1284 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1285 | .ok_or(RepositoryError::WorkingCopyRecordNotFound { id: working_copy })?; |
| 1286 | let target_view = txn |
| 1287 | .get_view(view) |
| 1288 | .map_err(|error| RepositoryError::Database(error.to_string()))? |
| 1289 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 1290 | name: view.to_string(), |
| 1291 | })?; |
| 1292 | (record, target_view) |
| 1293 | }; |
| 1294 | let mut target = operation::working_copy_state_ref(record); |
| 1295 | target.desired_view = target_view.id; |
| 1296 | target.desired_state = target_view.state; |
| 1297 | target.materialized_state = None; |
| 1298 | target.materialized_manifest = None; |
| 1299 | self.apply_working_copy_state_locked(&operation_lock, &target) |
| 1300 | } |
| 1301 | |
| 1302 | /// Set the current view on this handle only. |
| 1303 | /// |