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

Method open

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

Open an existing repository. This searches for a `.atomic` directory starting from the given path and walking up to parent directories. # Arguments `path` - A path inside the repository (or the repository root) # Errors Returns an error if no repository is found.

(path: P)

Source from the content-addressed store, hash-verified

301 ///
302 /// Returns an error if no repository is found.
303 pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, RepositoryError> {
304 if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) {
305 return Self::open_sandbox(working_root, canonical, &view);
306 }
307 let root = Self::find_root(path.as_ref())?;
308 let dot_dir = root.join(DOT_DIR);
309
310 // Open the pristine database
311 let pristine = Arc::new(
312 Pristine::open(dot_dir.join("pristine.redb"))
313 .map_err(|e| RepositoryError::Database(e.to_string()))?,
314 );
315
316 // Read current view from config or use default
317 let current_view =
318 Self::read_current_view(&dot_dir).unwrap_or_else(|_| DEFAULT_STACK.to_string());
319
320 // Open the change store
321 let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY)
322 .map_err(|e| RepositoryError::Database(e.to_string()))?;
323
324 Ok(Self {
325 root,
326 dot_dir,
327 current_view,
328 pristine,
329 change_store,
330 })
331 }
332
333 /// Open an existing repository without the table-init write lock.
334 ///

Callers

nothing calls this directly

Calls 2

detect_sandboxFunction · 0.85
as_refMethod · 0.80

Tested by

no test coverage detected