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

Method visible_file_paths

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

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