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)
| 159 | /// entry) are NOT returned — they persist across switches as |
| 160 | /// working-copy state. |
| 161 | pub fn visible_file_paths(&self, view_name: &str) -> Result<HashSet<String>, RepositoryError> { |
| 162 | let txn = self |
| 163 | .pristine |
| 164 | .read_txn() |
| 165 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 166 | |
| 167 | let view = match txn |
| 168 | .get_view(view_name) |
| 169 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 170 | { |
| 171 | Some(s) => s, |
| 172 | None => return Ok(HashSet::new()), |
| 173 | }; |
| 174 | |
| 175 | // Use the FULL visible change set (own + parent chain) so that |
| 176 | // draft views parented on dev see dev's files. |
| 177 | let view_change_ids = collect_visible_change_ids(&txn, &view)?; |
| 178 | |
| 179 | // Walk TREE and keep paths whose introducing change is in the log. |
| 180 | let mut paths: HashSet<String> = HashSet::new(); |
| 181 | let tree_iter = txn |
| 182 | .iter_tree() |
| 183 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 184 | |
| 185 | for result in tree_iter { |
| 186 | let (path, inode) = result.map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 187 | if let Some(position) = txn |
| 188 | .inode_position(inode) |
| 189 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 190 | { |
| 191 | if view_change_ids.contains(&position.change) { |
| 192 | paths.insert(path); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | Ok(paths) |
| 198 | } |
| 199 | |
| 200 | /// Materialize the working copy to match the current view's state. |
| 201 | /// |
no test coverage detected