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

Method set_current_view

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

665 /// Returns an error if the view does not exist or the pointer file
666 /// cannot be written.
667 pub fn set_current_view(&mut self, view: &str) -> Result<(), RepositoryError> {
668 // Verify the view exists in the pristine database
669 {
670 let txn = self
671 .pristine
672 .read_txn()
673 .map_err(|e| RepositoryError::Database(e.to_string()))?;
674
675 if txn
676 .get_view(view)
677 .map_err(|e| RepositoryError::Database(e.to_string()))?
678 .is_none()
679 {
680 return Err(RepositoryError::ViewNotFound {
681 name: view.to_string(),
682 });
683 }
684 }
685
686 self.write_current_view(view)?;
687 self.current_view = view.to_string();
688 Ok(())
689 }
690
691 /// Align the view pointer without materializing the working copy.
692 ///

Calls 4

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