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)
| 541 | /// } |
| 542 | /// ``` |
| 543 | pub fn get_tracked_file<T>(txn: &T, path: &str) -> RecordResult<Option<TrackedFile>> |
| 544 | where |
| 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 | /// |
nothing calls this directly
no test coverage detected