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

Method visible_file_paths

atomic-repository/src/repository/materialize.rs:1014–1090  ·  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

1012 /// entry) are NOT returned — they persist across switches as
1013 /// working-copy state.
1014 pub fn visible_file_paths(&self, view_name: &str) -> Result<HashSet<String>, RepositoryError> {
1015 let txn = self
1016 .pristine
1017 .read_txn()
1018 .map_err(|e| RepositoryError::Database(e.to_string()))?;
1019
1020 let view = txn
1021 .get_view(view_name)
1022 .map_err(|e| RepositoryError::Database(e.to_string()))?
1023 .ok_or_else(|| RepositoryError::ViewNotFound {
1024 name: view_name.to_string(),
1025 })?;
1026 let visibility = graph_visibility_closure(&txn, &view)?;
1027 let projection = self.project_tree_for_visibility(&txn, &visibility)?;
1028
1029 // Base set: the path-claim-aware projection (CB-13D machinery).
1030 let mut paths: HashSet<String> = projection
1031 .present
1032 .into_iter()
1033 .filter_map(|(path, item)| (!item.is_directory).then_some(path))
1034 .collect();
1035
1036 // CB-9A #199 recovery: the effective visible change set (own +
1037 // parent chain) decides whether a REV_TREE-claimed path is still
1038 // rendered by the view's filter.
1039 let view_change_ids: std::collections::HashSet<atomic_core::types::NodeId> =
1040 visibility.iter_dependency_first().copied().collect();
1041
1042 // REV_TREE recovery: a view is a FILTER over the global graph — every
1043 // node it exposes already lives in the graph, and TREE is just a
1044 // single-valued bookkeeping index over that graph. When two inodes
1045 // claim the same path (cross-view creates, a materialization
1046 // name-conflict), iter_tree can only expose the one binding — so a
1047 // switch used to classify a path that the target view's filter DOES
1048 // render as "absent from the new view" and silently DELETED it (see
1049 // `switch_file_loss_tests`). Re-insert any path that the filter
1050 // renders: some REV_TREE-claimed inode whose introducing change is
1051 // visible on the view AND alive under that filter — the same
1052 // predicate the materializer's name-conflict detection uses.
1053 {
1054 use atomic_core::pristine::TreeTxnT;
1055 let mut by_path: std::collections::HashMap<String, Vec<Inode>> =
1056 std::collections::HashMap::new();
1057 if let Ok(pairs) = txn.iter_rev_tree() {
1058 for (inode, path) in pairs {
1059 by_path.entry(path).or_default().push(inode);
1060 }
1061 }
1062 for (path, inodes) in by_path {
1063 if paths.contains(&path) {
1064 continue;
1065 }
1066 for inode in inodes {
1067 if let Ok(Some(position)) = txn.inode_position(inode) {
1068 if !view_change_ids.contains(&position.change) {
1069 continue;
1070 }
1071 // The filter exposes this path only if the claimed

Calls 14

graph_visibility_closureFunction · 0.85
read_txnMethod · 0.80
iter_dependency_firstMethod · 0.80
iter_rev_treeMethod · 0.80
get_viewMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
pushMethod · 0.45
containsMethod · 0.45
inode_positionMethod · 0.45