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

Method open

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

312 ///
313 /// Returns an error if no repository is found.
314 pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, RepositoryError> {
315 if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) {
316 return Self::open_sandbox(working_root, canonical, &view);
317 }
318 let root = Self::find_root(path.as_ref())?;
319 let dot_dir = root.join(DOT_DIR);
320
321 // Open the pristine database
322 let pristine = Arc::new(
323 Pristine::open(dot_dir.join("pristine.redb"))
324 .map_err(|e| RepositoryError::Database(e.to_string()))?,
325 );
326
327 // Read current view from config or use default
328 let current_view =
329 Self::read_current_view(&dot_dir).unwrap_or_else(|_| DEFAULT_STACK.to_string());
330
331 // Open the change store
332 let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY)
333 .map_err(|e| RepositoryError::Database(e.to_string()))?;
334
335 let mut repository = Self {
336 root,
337 dot_dir,
338 current_view,
339 pristine,
340 change_store,
341 is_sandbox: false,
342 };
343 repository.recover_pending_deferred_tree_alignment()?;
344 Ok(repository)
345 }
346
347 /// Open an existing repository without the table-init write lock.
348 ///

Callers 1

Calls 3

detect_sandboxFunction · 0.85
as_refMethod · 0.80

Tested by

no test coverage detected