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

Method align_to_view

atomic-repository/src/repository/mod.rs:1270–1300  ·  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

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

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