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

Method set_current_view

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

Set the current view (internal, does not update working copy). Update the view pointer on disk without materializing. This updates both the in-memory state and persists the change to disk, but does **NOT** update the working copy. The working copy may be left inconsistent with the view pointer — `status()` handles this gracefully (files tracked on other views show as `Added` rather than `Untrac

(&mut self, view: &str)

Source from the content-addressed store, hash-verified

612 /// Returns an error if the view does not exist or the pointer file
613 /// cannot be written.
614 pub fn set_current_view(&mut self, view: &str) -> Result<(), RepositoryError> {
615 // Verify the view exists in the pristine database
616 {
617 let txn = self
618 .pristine
619 .read_txn()
620 .map_err(|e| RepositoryError::Database(e.to_string()))?;
621
622 if txn
623 .get_view(view)
624 .map_err(|e| RepositoryError::Database(e.to_string()))?
625 .is_none()
626 {
627 return Err(RepositoryError::ViewNotFound {
628 name: view.to_string(),
629 });
630 }
631 }
632
633 self.current_view = view.to_string();
634 self.write_current_view(view)?;
635 Ok(())
636 }
637
638 /// Align the view pointer without materializing the working copy.
639 ///

Calls 4

read_txnMethod · 0.80
is_noneMethod · 0.80
write_current_viewMethod · 0.80
get_viewMethod · 0.45