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

Method open_for_workspace_transaction

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

Open an existing repository for a workspace transaction preflight. This constructor supports later writes but performs no migration, operation recovery, head consolidation, compatibility-file rewrite, or table initialization. Callers must immediately enter [`Self::begin_workspace_txn`], which observes and classifies Git state before any recovery mutation.

(
        path: P,
    )

Source from the content-addressed store, hash-verified

763 /// initialization. Callers must immediately enter [`Self::begin_workspace_txn`],
764 /// which observes and classifies Git state before any recovery mutation.
765 pub fn open_for_workspace_transaction<P: AsRef<Path>>(
766 path: P,
767 ) -> Result<Self, RepositoryError> {
768 if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) {
769 database::require_current_database(&Self::canonical_dot_dir(&canonical)?)?;
770 // CB-13D ::24 R1: this constructor performs NO recovery on
771 // either path (the ordinary path defers everything to
772 // begin_workspace_txn), so the sandbox path matches it and
773 // returns without a recovery gate by design.
774 return Self::open_sandbox(working_root, canonical, &view);
775 }
776 let layout = working_copy::discover_layout(path.as_ref())?;
777 let root = layout.working_root.clone();
778 let dot_dir = layout.common_dot_dir.clone();
779 let pristine = Arc::new(
780 Pristine::open_existing(database::require_current_database(&dot_dir)?)
781 .map_err(RepositoryError::from)?,
782 );
783 let (_working_copy_id, current_view) =
784 working_copy::load_registered_identity(&pristine, &layout)?;
785 let change_store =
786 ChangeStore::open_existing(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY)
787 .map_err(|error| RepositoryError::Database(error.to_string()))?;
788
789 Ok(Self {
790 root,
791 dot_dir,
792 current_view,
793 pristine,
794 change_store,
795 is_sandbox: false,
796 semantic_closure_memo: Default::default(),
797 })
798 }
799
800 /// Open an existing repository in read-only mode.
801 ///

Callers

nothing calls this directly

Calls 6

detect_sandboxFunction · 0.85
require_current_databaseFunction · 0.85
discover_layoutFunction · 0.85
load_registered_identityFunction · 0.85
as_refMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected