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, repo_root: PathBuf)
| 485 | /// This is the main entry point for the pull operation. It coordinates |
| 486 | /// all the steps required to download and apply remote changes. |
| 487 | async fn run_async(&self, repo_root: PathBuf) -> CliResult<()> { |
| 488 | // Open the repository and enter the shared workspace transaction for the |
| 489 | // whole boundary. Dry runs observe without mutation — the boundary opens |
| 490 | // read-only so Observe is mutation-free by construction; ordinary pulls |
| 491 | // reconcile safe drift and refuse unsafe baselines before any network |
| 492 | // or graph work. WorkspaceTxn authority (working copy + view) is |
| 493 | // retained for the entire command body. |
| 494 | let mut repo = if self.dry_run { |
| 495 | Repository::open_readonly(&repo_root) |
| 496 | } else { |
| 497 | Repository::open_for_workspace_transaction(&repo_root) |
| 498 | } |
| 499 | .map_err(CliError::Repository)?; |
| 500 | let workspace = enter_workspace(&mut repo, boundary_mode(self.dry_run))?; |
| 501 | let working_copy = workspace.working_copy(); |
| 502 | let desired_view = workspace.view().name.clone(); |
| 503 | |
| 504 | // Resolve remote name, URL, and identity hint |
| 505 | let (remote_name, remote_url, identity_hint) = self.resolve_remote_url(&repo)?; |
| 506 | |
| 507 | // Determine views. The remote view defaults to the working copy's desired |
| 508 | // view; the local view defaults to the remote view being pulled, so |
| 509 | // `atomic pull --from-view X` pulls into a local view named `X`. |
| 510 | let remote_view = self.get_remote_view(&desired_view); |
| 511 | let local_view = self.get_local_view(&remote_view); |
| 512 | |
| 513 | // Whether the local target view already exists. Creation is deferred |
| 514 | // until the remote manifest is known (below), so a pulled draft can be |
| 515 | // created with the remote's identity (scope + parent) — inheriting its |
| 516 | // parent's history — instead of a flat shared view. |
| 517 | let local_view_exists = repo |
| 518 | .view_exists(&local_view) |
| 519 | .map_err(CliError::Repository)?; |
| 520 | |
| 521 | // Print header |
| 522 | println!( |
| 523 | "Pulling from {} ({})", |
| 524 | style_view(&remote_name), |
| 525 | hint(&remote_url) |
| 526 | ); |
| 527 | |
| 528 | // Connect to remote |
| 529 | let spinner = create_spinner("Connecting to remote..."); |
| 530 | let config = self |
| 531 | .build_remote_config(&remote_url, identity_hint.as_deref()) |
| 532 | .await; |
| 533 | let remote = HttpRemote::with_config(&remote_url, config).map_err(|e| { |
| 534 | finish_error(&spinner, "Failed to connect"); |
| 535 | convert_remote_error(e, &remote_url) |
| 536 | })?; |
| 537 | finish_success(&spinner, "Connected"); |
| 538 | |
| 539 | // Load the target view's history for display only. Object negotiation is |
| 540 | // graph-wide: `haves` is every change node already registered in the |
| 541 | // common pristine, regardless of which view metadata currently exposes |
| 542 | // it. This prevents the server from resending shared-view nodes when a |
| 543 | // draft's own local log is empty. |
| 544 | let spinner = create_spinner("Loading local history..."); |
no test coverage detected