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

Method run_async

atomic-cli/src/commands/pull/command.rs:479–988  ·  view source on GitHub ↗

Async implementation of the pull command. This is the main entry point for the pull operation. It coordinates all the steps required to download and apply remote changes.

(&self)

Source from the content-addressed store, hash-verified

477 /// This is the main entry point for the pull operation. It coordinates
478 /// all the steps required to download and apply remote changes.
479 async fn run_async(&self) -> CliResult<()> {
480 // Find and open repository
481 let repo_root = find_repository_root()?;
482 let mut repo = Repository::open(&repo_root).map_err(CliError::Repository)?;
483
484 // Resolve remote name, URL, and identity hint
485 let (remote_name, remote_url, identity_hint) = self.resolve_remote_url(&repo)?;
486
487 // Determine views. The remote view defaults to the current view; the
488 // local view defaults to the remote view being pulled, so
489 // `atomic pull --from-view X` pulls into a local view named `X`.
490 let remote_view = self.get_remote_view(repo.current_view());
491 let local_view = self.get_local_view(&remote_view);
492
493 // Whether the local target view already exists. Creation is deferred
494 // until the remote manifest is known (below), so a pulled draft can be
495 // created with the remote's identity (scope + parent) — inheriting its
496 // parent's history — instead of a flat shared view.
497 let local_view_exists = repo
498 .view_exists(&local_view)
499 .map_err(CliError::Repository)?;
500
501 // Print header
502 println!(
503 "Pulling from {} ({})",
504 style_view(&remote_name),
505 hint(&remote_url)
506 );
507
508 // Connect to remote
509 let spinner = create_spinner("Connecting to remote...");
510 let config = self
511 .build_remote_config(&remote_url, identity_hint.as_deref())
512 .await;
513 let remote = HttpRemote::with_config(&remote_url, config).map_err(|e| {
514 finish_error(&spinner, "Failed to connect");
515 convert_remote_error(e, &remote_url)
516 })?;
517 finish_success(&spinner, "Connected");
518
519 // Load the target view's history for display only. Object negotiation is
520 // graph-wide: `haves` is every change node already registered in the
521 // common pristine, regardless of which view metadata currently exposes
522 // it. This prevents the server from resending shared-view nodes when a
523 // draft's own local log is empty.
524 let spinner = create_spinner("Loading local history...");
525 let local_entries = if local_view_exists {
526 repo.log(HistoryOptions::new().view(&local_view))
527 .map_err(CliError::Repository)?
528 } else {
529 Vec::new()
530 };
531 let haves: Vec<String> = repo
532 .registered_change_hashes()
533 .map_err(CliError::Repository)?
534 .into_iter()
535 .map(|hash| hash.to_base32())
536 .collect();

Callers 1

runMethod · 0.45

Calls 15

find_repository_rootFunction · 0.85
create_spinnerFunction · 0.85
finish_errorFunction · 0.85
finish_successFunction · 0.85
manifest_chain_from_packFunction · 0.85
print_blankFunction · 0.85
display_state_comparisonFunction · 0.85
has_local_only_changesFunction · 0.85
find_local_only_changesFunction · 0.85
pack_objects_by_keyFunction · 0.85
create_progress_barFunction · 0.85
print_warningFunction · 0.85

Tested by

no test coverage detected