Compute the set of file paths visible on a view. Visibility includes the view's own changes AND all changes inherited through the parent chain. A draft view parented on dev sees dev's files without requiring an explicit insert. A file is visible on a view when: 1. It appears in the global TREE table (has been `add`ed). 2. Its inode has a graph position in the INODES table (has been `record`ed).
(&self, view_name: &str)
| 19 | /// entry) are NOT returned — they persist across switches as |
| 20 | /// working-copy state. |
| 21 | pub fn visible_file_paths(&self, view_name: &str) -> Result<HashSet<String>, RepositoryError> { |
| 22 | let txn = self |
| 23 | .pristine |
| 24 | .read_txn() |
| 25 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 26 | |
| 27 | let view = match txn |
| 28 | .get_view(view_name) |
| 29 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 30 | { |
| 31 | Some(s) => s, |
| 32 | None => return Ok(HashSet::new()), |
| 33 | }; |
| 34 | |
| 35 | // Use the FULL visible change set (own + parent chain) so that |
| 36 | // draft views parented on dev see dev's files. |
| 37 | let view_change_ids = collect_visible_change_ids(&txn, &view)?; |
| 38 | |
| 39 | // Walk TREE and keep paths whose introducing change is in the log. |
| 40 | let mut paths: HashSet<String> = HashSet::new(); |
| 41 | let tree_iter = txn |
| 42 | .iter_tree() |
| 43 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 44 | |
| 45 | for result in tree_iter { |
| 46 | let (path, inode) = result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 47 | if let Some(position) = txn |
| 48 | .inode_position(inode) |
| 49 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 50 | { |
| 51 | if view_change_ids.contains(&position.change) { |
| 52 | paths.insert(path); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | Ok(paths) |
| 58 | } |
| 59 | |
| 60 | /// Materialize the working copy to match the current view's state. |
| 61 | /// |
no test coverage detected