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

Method visible_file_paths

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

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 ///

Callers 4

materialize_view_toMethod · 0.80
stageMethod · 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