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

Method run_two_tier

atomic-cli/src/commands/view/new.rs:253–299  ·  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

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

Tested by

no test coverage detected