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

Method set_view_scope

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

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