Collect tracked files from the pristine database. Iterates over the TREE table to find all files tracked by the repository. Results can be filtered by path prefix. # Arguments `txn` - Read transaction for pristine database `prefix` - Path prefix filter (empty = all files) # Returns A `CollectionResult ` containing all tracked files. # Errors Returns `RecordError::Pristine` if da
(
txn: &T,
prefix: &str,
)
| 357 | /// let result = collect_tracked_files(&txn, "src/")?; |
| 358 | /// ``` |
| 359 | pub fn collect_tracked_files<T>( |
| 360 | txn: &T, |
| 361 | prefix: &str, |
| 362 | ) -> RecordResult<CollectionResult<TrackedFile>> |
| 363 | where |
| 364 | T: GraphTxnT + TreeTxnT + ViewTxnT, |
| 365 | { |
| 366 | let mut result = CollectionResult::new(); |
| 367 | |
| 368 | // Iterate over all tree entries (trait doesn't support prefix filtering) |
| 369 | let iter = txn |
| 370 | .iter_tree() |
| 371 | .map_err(|e| RecordError::Pristine(Box::new(e)))?; |
| 372 | |
| 373 | for item in iter { |
| 374 | match item { |
| 375 | Ok((path, inode)) => { |
| 376 | // Filter by prefix if specified |
| 377 | if !prefix.is_empty() && !path.starts_with(prefix) { |
| 378 | result.add_skipped(); |
| 379 | continue; |
| 380 | } |
| 381 | |
| 382 | // Get the position for this inode |
| 383 | match txn.inode_position(inode) { |
| 384 | Ok(Some(position)) => { |
| 385 | let file = TrackedFile::new(&path, inode, position); |
| 386 | result.add(file); |
| 387 | } |
| 388 | Ok(None) => { |
| 389 | // Inode exists but has no position - might be a bug or deleted |
| 390 | result.add_error(&path, "Inode has no graph position"); |
| 391 | } |
| 392 | Err(e) => { |
| 393 | result.add_error(&path, format!("Failed to get position: {}", e)); |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | Err(e) => { |
| 398 | result.add_error("<iteration error>", format!("Tree iteration failed: {}", e)); |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | Ok(result) |
| 404 | } |
| 405 | |
| 406 | /// Collect files from the working copy. |
| 407 | /// |
nothing calls this directly
no test coverage detected