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

Method run_two_tier

atomic-cli/src/commands/view/new.rs:250–296  ·  view source on GitHub ↗

Two-tier view creation: --draft and/or --parent

(&self, name: &str, repo: &mut Repository)

Source from the content-addressed store, hash-verified

248
249 /// Two-tier view creation: --draft and/or --parent
250 fn run_two_tier(&self, name: &str, repo: &mut Repository) -> CliResult<()> {
251 use atomic_core::pristine::{MutTxnT, ViewScope, ViewTxnT};
252
253 let kind = if self.draft {
254 ViewScope::Draft
255 } else {
256 ViewScope::Shared
257 };
258
259 // Resolve the parent view name → ID
260 let parent_name = self
261 .parent
262 .clone()
263 .unwrap_or_else(|| repo.current_view().to_string());
264
265 let mut txn = repo
266 .pristine()
267 .write_txn()
268 .map_err(|e| CliError::Internal(e.into()))?;
269
270 let parent_view = txn
271 .get_view(&parent_name)
272 .map_err(|e| CliError::Internal(e.into()))?
273 .ok_or_else(|| CliError::ViewNotFound {
274 name: parent_name.clone(),
275 })?;
276
277 let parent_id = parent_view.id;
278
279 // Create the view with explicit kind and parent
280 let _view = txn
281 .create_view(name, kind, Some(parent_id))
282 .map_err(|e| CliError::Internal(e.into()))?;
283
284 txn.commit().map_err(|e| CliError::Internal(e.into()))?;
285
286 let kind_label = if kind.is_draft() { "draft" } else { "shared" };
287
288 print_success(&format!(
289 "Created {} view: {} (parent: {})",
290 kind_label,
291 style_view(name),
292 style_view(&parent_name),
293 ));
294
295 self.maybe_switch(name, repo)
296 }
297
298 /// Optionally switch to the new view and print hint.
299 fn maybe_switch(&self, name: &str, repo: &mut Repository) -> CliResult<()> {

Callers 1

runMethod · 0.80

Calls 10

print_successFunction · 0.85
current_viewMethod · 0.80
write_txnMethod · 0.80
pristineMethod · 0.80
commitMethod · 0.80
is_draftMethod · 0.80
maybe_switchMethod · 0.80
cloneMethod · 0.45
get_viewMethod · 0.45
create_viewMethod · 0.45

Tested by

no test coverage detected