Clone every remote view not already applied by the primary chain. Each view arrives as a manifest and is applied with the same primitive as the primary view, so scope and parent are preserved. Manifests are ordered parents-before-children; changes are content-addressed and deduplicated against everything already downloaded. Returns the number of additional views cloned.
(
&self,
repo: &mut Repository,
remote: &HttpRemote,
stats: &mut CloneStats,
applied: &mut HashSet<String>,
)
| 600 | /// content-addressed and deduplicated against everything already |
| 601 | /// downloaded. Returns the number of additional views cloned. |
| 602 | async fn clone_additional_views( |
| 603 | &self, |
| 604 | repo: &mut Repository, |
| 605 | remote: &HttpRemote, |
| 606 | stats: &mut CloneStats, |
| 607 | applied: &mut HashSet<String>, |
| 608 | ) -> CliResult<usize> { |
| 609 | // The user explicitly asked for every view, so a missing inventory |
| 610 | // is a hard error, not a silent single-view clone. |
| 611 | let remote_views = remote |
| 612 | .list_views() |
| 613 | .await |
| 614 | .map_err(|e| CliError::RemoteError { |
| 615 | message: format!( |
| 616 | "--all-views requires the view inventory (?views), but the request failed: {}", |
| 617 | e |
| 618 | ), |
| 619 | url: Some(self.url.clone()), |
| 620 | })?; |
| 621 | |
| 622 | let names: Vec<String> = remote_views.into_iter().map(|v| v.name).collect(); |
| 623 | let others = match classify_inventory(&names, applied) { |
| 624 | InventoryOutcome::Views(others) => others, |
| 625 | InventoryOutcome::NothingNew => return Ok(0), |
| 626 | InventoryOutcome::Unsupported => { |
| 627 | return Err(CliError::RemoteError { |
| 628 | message: "--all-views requires the view inventory (?views), but this \ |
| 629 | server does not support it (empty inventory). Upgrade the \ |
| 630 | server, or clone a single view without --all-views." |
| 631 | .to_string(), |
| 632 | url: Some(self.url.clone()), |
| 633 | }) |
| 634 | } |
| 635 | }; |
| 636 | |
| 637 | print_blank(); |
| 638 | println!( |
| 639 | "Cloning {} additional {}:", |
| 640 | others.len(), |
| 641 | if others.len() == 1 { "view" } else { "views" } |
| 642 | ); |
| 643 | |
| 644 | // Fetch manifests for every remaining view. |
| 645 | let mut manifests: Vec<ViewManifest> = Vec::with_capacity(others.len()); |
| 646 | for name in &others { |
| 647 | match self.fetch_view_manifest(remote, name).await { |
| 648 | Ok(Some(m)) => manifests.push(m), |
| 649 | Ok(None) => { |
| 650 | print_warning(&format!( |
| 651 | "View '{}' vanished from the remote — skipped", |
| 652 | name |
| 653 | )); |
| 654 | } |
| 655 | Err(e) => { |
| 656 | print_warning(&format!( |
| 657 | "Failed to fetch manifest for view '{}': {}", |
| 658 | name, e |
| 659 | )); |
no test coverage detected