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

Method set_view_scope

atomic-repository/src/repository/views.rs:161–187  ·  view source on GitHub ↗

Change a view's scope between Draft and Shared. This is useful after `git import` which creates Draft views by default.

(&self, name: &str, scope: ViewScope)

Source from the content-addressed store, hash-verified

159 /// This is useful after `git import` which creates Draft views by
160 /// default.
161 pub fn set_view_scope(&self, name: &str, scope: ViewScope) -> Result<(), RepositoryError> {
162 let mut txn = self
163 .pristine
164 .write_txn()
165 .map_err(|e| RepositoryError::Database(e.to_string()))?;
166
167 let mut view = txn
168 .get_view(name)
169 .map_err(|e| RepositoryError::Database(e.to_string()))?
170 .ok_or_else(|| RepositoryError::ViewNotFound {
171 name: name.to_string(),
172 })?;
173
174 view.kind = scope;
175 // Clear parent when promoting to Shared root view
176 if scope.is_shared() {
177 view.parent = None;
178 }
179
180 txn.update_view(&view)
181 .map_err(|e| RepositoryError::Database(e.to_string()))?;
182
183 txn.commit()
184 .map_err(|e| RepositoryError::Database(e.to_string()))?;
185
186 Ok(())
187 }
188
189 /// Walk the parent chain from `view_name` and return the name of the
190 /// first Shared view encountered. If `view_name` is itself Shared,

Callers 1

runMethod · 0.80

Calls 5

write_txnMethod · 0.80
is_sharedMethod · 0.80
update_viewMethod · 0.80
commitMethod · 0.80
get_viewMethod · 0.45

Tested by

no test coverage detected