Load a change's provenance graphs: REV_DEPS-backed lookup, with a disk-scan fallback when REV_DEPS registration missed the change. Errors if no graph explains the change.
(repo: &Repository, change_hash: &Hash)
| 146 | /// fallback when REV_DEPS registration missed the change. Errors if no graph |
| 147 | /// explains the change. |
| 148 | fn load_graphs(repo: &Repository, change_hash: &Hash) -> CliResult<Vec<(Hash, ProvenanceGraph)>> { |
| 149 | let mut graphs = repo |
| 150 | .find_provenance_for_change(change_hash) |
| 151 | .map_err(CliError::Repository)?; |
| 152 | if graphs.is_empty() { |
| 153 | graphs = repo |
| 154 | .find_provenance_for_change_scan(change_hash) |
| 155 | .map_err(CliError::Repository)?; |
| 156 | } |
| 157 | if graphs.is_empty() { |
| 158 | return Err(CliError::InvalidArgument { |
| 159 | message: format!( |
| 160 | "no provenance graph explains change {}", |
| 161 | change_hash.to_base32() |
| 162 | ), |
| 163 | }); |
| 164 | } |
| 165 | // Most-recent first (a change explained by >1 graph shows all; the newest |
| 166 | // leads). Both loaders sort/return unspecified order, so sort here. |
| 167 | graphs.sort_by_key(|(_, g)| std::cmp::Reverse(g.timestamp)); |
| 168 | Ok(graphs) |
| 169 | } |
| 170 | |
| 171 | /// Resolve the CLI target (bare hash, hash prefix, or `urn:atomic:change:<b32>`) |
| 172 | /// to a change `Hash`. |
no test coverage detected