Fetch the requested view's manifest and walk its parent chain up to the root, returning the manifests in root→leaf apply order. Returns `Ok(None)` when the requested view does not exist on the remote. A declared parent that is missing remotely, or a parent chain that loops, means the remote's view metadata is corrupted and is a hard error.
(&self, pack: &SyncPack)
| 456 | /// that loops, means the remote's view metadata is corrupted and is a |
| 457 | /// hard error. |
| 458 | fn fetch_manifest_chain(&self, pack: &SyncPack) -> CliResult<Option<Vec<ViewManifest>>> { |
| 459 | let Some(leaf) = self.view_manifest_from_pack(pack, &self.view)? else { |
| 460 | return Ok(None); |
| 461 | }; |
| 462 | |
| 463 | let mut visited: HashSet<String> = HashSet::new(); |
| 464 | visited.insert(leaf.name.clone()); |
| 465 | let mut next_parent = leaf.parent.clone(); |
| 466 | let mut chain = vec![leaf]; |
| 467 | |
| 468 | while let Some(parent) = next_parent { |
| 469 | if !visited.insert(parent.clone()) { |
| 470 | return Err(CliError::RemoteError { |
| 471 | message: format!( |
| 472 | "View parent chain loops at '{}' — the remote's view metadata is corrupted", |
| 473 | parent |
| 474 | ), |
| 475 | url: Some(self.url.clone()), |
| 476 | }); |
| 477 | } |
| 478 | let child_name = chain |
| 479 | .last() |
| 480 | .map(|m| m.name.clone()) |
| 481 | .unwrap_or_else(|| self.view.clone()); |
| 482 | let manifest = self |
| 483 | .view_manifest_from_pack(pack, &parent)? |
| 484 | .ok_or_else(|| CliError::RemoteError { |
| 485 | message: format!( |
| 486 | "View '{}' declares parent '{}', but the remote has no such view", |
| 487 | child_name, parent |
| 488 | ), |
| 489 | url: Some(self.url.clone()), |
| 490 | })?; |
| 491 | next_parent = manifest.parent.clone(); |
| 492 | chain.push(manifest); |
| 493 | } |
| 494 | |
| 495 | // Collected leaf→root; parents must be applied first. |
| 496 | chain.reverse(); |
| 497 | Ok(Some(chain)) |
| 498 | } |
| 499 | |
| 500 | /// Download every change in `missing` and save it to the change store. |
| 501 | /// |