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

Method set_view_scope

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

252 /// This is useful after `git import` which creates Draft views by
253 /// default.
254 pub fn set_view_scope(&self, name: &str, scope: ViewScope) -> Result<(), RepositoryError> {
255 self.ensure_project_identity(atomic_core::kg::project_id::MintReason::Upgrade)?;
256 let mut txn = self
257 .pristine
258 .write_txn()
259 .map_err(|e| RepositoryError::Database(e.to_string()))?;
260
261 let mut view = txn
262 .get_view(name)
263 .map_err(|e| RepositoryError::Database(e.to_string()))?
264 .ok_or_else(|| RepositoryError::ViewNotFound {
265 name: name.to_string(),
266 })?;
267
268 if scope.is_shared() {
269 self.ensure_view_has_no_snapshots(&txn, &view)?;
270 }
271 view.kind = scope;
272 // Clear parent when promoting to Shared root view
273 if scope.is_shared() {
274 view.parent = None;
275 }
276
277 txn.update_view(&view)
278 .map_err(|e| RepositoryError::Database(e.to_string()))?;
279
280 super::name_resolution::refresh_name_conflict_caches(&mut txn, view.id)?;
281
282 if txn.kg_writes_enabled()? {
283 self.project_view_kg(&mut txn)?;
284 }
285
286 txn.commit()
287 .map_err(|e| RepositoryError::Database(e.to_string()))?;
288
289 Ok(())
290 }
291
292 /// Repair an existing view's full identity (scope **and** parent) to match
293 /// a declared manifest/snapshot.

Calls 10

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