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

Method align_to_view

atomic-repository/src/repository/mod.rs:1283–1313  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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 ///

Callers 11

runMethod · 0.45
run_importMethod · 0.45
clone_git_urlFunction · 0.45
run_asyncMethod · 0.45
test_list_after_switchFunction · 0.45
handle_session_endMethod · 0.45
handle_session_startMethod · 0.45

Calls 7

working_copy_state_refFunction · 0.85
try_lock_operationMethod · 0.80
read_txnMethod · 0.80
get_working_copyMethod · 0.45
get_viewMethod · 0.45

Tested by 1

test_list_after_switchFunction · 0.36