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

Method visible_file_paths

atomic-repository/src/repository/materialize.rs:235–272  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

233 /// entry) are NOT returned — they persist across switches as
234 /// working-copy state.
235 pub fn visible_file_paths(&self, view_name: &str) -> Result<HashSet<String>, RepositoryError> {
236 let txn = self
237 .pristine
238 .read_txn()
239 .map_err(|e| RepositoryError::Database(e.to_string()))?;
240
241 let view = match txn
242 .get_view(view_name)
243 .map_err(|e| RepositoryError::Database(e.to_string()))?
244 {
245 Some(s) => s,
246 None => return Ok(HashSet::new()),
247 };
248
249 // Use the FULL visible change set (own + parent chain) so that
250 // draft views parented on dev see dev's files.
251 let view_change_ids = collect_visible_change_ids(&txn, &view)?;
252
253 // Walk TREE and keep paths whose introducing change is in the log.
254 let mut paths: HashSet<String> = HashSet::new();
255 let tree_iter = txn
256 .iter_tree()
257 .map_err(|e| RepositoryError::Database(e.to_string()))?;
258
259 for result in tree_iter {
260 let (path, inode) = result.map_err(|e| RepositoryError::Database(e.to_string()))?;
261 if let Some(position) = txn
262 .inode_position(inode)
263 .map_err(|e| RepositoryError::Database(e.to_string()))?
264 {
265 if view_change_ids.contains(&position.change) {
266 paths.insert(path);
267 }
268 }
269 }
270
271 Ok(paths)
272 }
273
274 /// Materialize the working copy to match the current view's state.
275 ///

Callers 5

materialize_view_toMethod · 0.80
stageMethod · 0.80
split_viewMethod · 0.80
switch_viewMethod · 0.80
verify_working_copyMethod · 0.80

Calls 7

read_txnMethod · 0.80
get_viewMethod · 0.45
iter_treeMethod · 0.45
inode_positionMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected