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

Function get_tracked_file

atomic-core/src/record/workflow/collect.rs:543–566  ·  view source on GitHub ↗

Get the pristine state for a single file. Looks up a file's tracked state in the pristine database. # Arguments `txn` - Read transaction for pristine database `path` - Path to look up # Returns `Some(TrackedFile)` if the file is tracked, `None` otherwise. # Example ```rust,ignore if let Some(tracked) = get_tracked_file(&txn, "src/main.rs")? { println!("File {} has inode {:?}", tracked.path,

(txn: &T, path: &str)

Source from the content-addressed store, hash-verified

541/// }
542/// ```
543pub fn get_tracked_file<T>(txn: &T, path: &str) -> RecordResult<Option<TrackedFile>>
544where
545 T: GraphTxnT + TreeTxnT + ViewTxnT,
546{
547 // Look up the inode for this path
548 let inode = match txn
549 .get_inode(path)
550 .map_err(|e| RecordError::Pristine(Box::new(e)))?
551 {
552 Some(inode) => inode,
553 None => return Ok(None),
554 };
555
556 // Get the position for this inode
557 let position = match txn
558 .inode_position(inode)
559 .map_err(|e| RecordError::Pristine(Box::new(e)))?
560 {
561 Some(pos) => pos,
562 None => return Ok(None),
563 };
564
565 Ok(Some(TrackedFile::new(path, inode, position)))
566}
567
568/// Get the working copy state for a single file.
569///

Callers

nothing calls this directly

Calls 3

PristineClass · 0.85
get_inodeMethod · 0.45
inode_positionMethod · 0.45

Tested by

no test coverage detected