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

Method set_view_scope

atomic-repository/src/repository/views.rs:178–204  ·  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

176 /// This is useful after `git import` which creates Draft views by
177 /// default.
178 pub fn set_view_scope(&self, name: &str, scope: ViewScope) -> Result<(), RepositoryError> {
179 let mut txn = self
180 .pristine
181 .write_txn()
182 .map_err(|e| RepositoryError::Database(e.to_string()))?;
183
184 let mut view = txn
185 .get_view(name)
186 .map_err(|e| RepositoryError::Database(e.to_string()))?
187 .ok_or_else(|| RepositoryError::ViewNotFound {
188 name: name.to_string(),
189 })?;
190
191 view.kind = scope;
192 // Clear parent when promoting to Shared root view
193 if scope.is_shared() {
194 view.parent = None;
195 }
196
197 txn.update_view(&view)
198 .map_err(|e| RepositoryError::Database(e.to_string()))?;
199
200 txn.commit()
201 .map_err(|e| RepositoryError::Database(e.to_string()))?;
202
203 Ok(())
204 }
205
206 /// Walk the parent chain from `view_name` and return the name of the
207 /// first Shared view encountered. If `view_name` is itself Shared,

Calls 5

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