The local `build_view_chain` — the ancestor chain, root → leaf, with the cycle guard.
(repo: &Repository, leaf: &str)
| 157 | /// The local `build_view_chain` — the ancestor chain, root → leaf, with |
| 158 | /// the cycle guard. |
| 159 | fn build_view_chain(repo: &Repository, leaf: &str) -> Result<Vec<String>, Status> { |
| 160 | let mut chain = vec![leaf.to_string()]; |
| 161 | let mut visited: HashSet<String> = HashSet::new(); |
| 162 | visited.insert(leaf.to_string()); |
| 163 | let mut current = leaf.to_string(); |
| 164 | loop { |
| 165 | let parent = repo |
| 166 | .get_view_info(¤t) |
| 167 | .map_err(|_| domain_status(ErrorCode::View, format!("view '{current}' not found")))? |
| 168 | .parent_name; |
| 169 | let Some(parent) = parent else { break }; |
| 170 | if !visited.insert(parent.clone()) { |
| 171 | return Err(domain_status( |
| 172 | ErrorCode::InvalidArgument, |
| 173 | format!("view parent chain contains a cycle at '{parent}'"), |
| 174 | )); |
| 175 | } |
| 176 | chain.push(parent.clone()); |
| 177 | current = parent; |
| 178 | } |
| 179 | chain.reverse(); |
| 180 | Ok(chain) |
| 181 | } |
| 182 | |
| 183 | /// The remote ref advertisement — the local `parse_advertisement`. |
| 184 | #[derive(Clone)] |
no test coverage detected