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

Method get_file_content_on_view

atomic-repository/src/repository/content.rs:363–394  ·  view source on GitHub ↗

Get the recorded content for a tracked file on a specific view. Like `get_file_content`, but reads from the specified view instead of the current view. This is a **read-only** operation — it does NOT call `set_current_view` or write anything to disk. # Arguments `path` - Path to the file (relative to repository root) `view_name` - The view to read from # Returns The file content as bytes, or

(
        &self,
        path: P,
        view_name: &str,
    )

Source from the content-addressed store, hash-verified

361 /// The file content as bytes, or `None` if the file is not tracked
362 /// on the specified view.
363 pub fn get_file_content_on_view<P: AsRef<Path>>(
364 &self,
365 path: P,
366 view_name: &str,
367 ) -> Result<Option<Vec<u8>>, RepositoryError> {
368 let path = path.as_ref();
369 let normalized = normalize_path(path);
370
371 let txn = self
372 .pristine
373 .read_txn()
374 .map_err(|e| RepositoryError::Database(e.to_string()))?;
375
376 // Get the specified view (read-only — no set_current_stack)
377 let view = txn
378 .get_view(view_name)
379 .map_err(|e| RepositoryError::Database(e.to_string()))?
380 .ok_or_else(|| RepositoryError::ViewNotFound {
381 name: view_name.to_string(),
382 })?;
383
384 let change_filter = if view.kind.is_shared() && view.parent.is_none() {
385 collect_view_change_ids(&txn, &view)?
386 } else {
387 collect_visible_change_ids_with_deps(&txn, &view)?
388 };
389
390 // Use the filtered retrieval method with cached graph access
391 let cached_txn =
392 CachedGraphTxn::new(&txn).map_err(|e| RepositoryError::Database(e.to_string()))?;
393 self.get_file_content_with_filter(&cached_txn, &normalized, change_filter, true)
394 }
395
396 /// Get the recorded content for a tracked file with options.
397 ///

Calls 9

collect_view_change_idsFunction · 0.85
as_refMethod · 0.80
read_txnMethod · 0.80
is_sharedMethod · 0.80
is_noneMethod · 0.80
normalize_pathFunction · 0.50
get_viewMethod · 0.45