The view-to-view diff: a pure read (read-only repository open) over each side's visible file set, unified-diffed with `similar` — the same hunk computation the working-copy diff performs.
(
root: &std::path::Path,
from_view: &str,
to_view: &str,
stat_only: bool,
)
| 901 | /// each side's visible file set, unified-diffed with `similar` — the |
| 902 | /// same hunk computation the working-copy diff performs. |
| 903 | fn compute_ref_pair_diff( |
| 904 | root: &std::path::Path, |
| 905 | from_view: &str, |
| 906 | to_view: &str, |
| 907 | stat_only: bool, |
| 908 | ) -> Result<Vec<DiffChunk>, Status> { |
| 909 | let repo = Repository::open_readonly_wait(root, super::state::database_open_wait()).map_err( |
| 910 | |error| { |
| 911 | domain_status( |
| 912 | ErrorCode::Repository, |
| 913 | format!("failed to open repository read-only: {error}"), |
| 914 | ) |
| 915 | }, |
| 916 | )?; |
| 917 | for view in [from_view, to_view] { |
| 918 | if !repo.view_exists(view).map_err(repository_error)? { |
| 919 | return Err(domain_status( |
| 920 | ErrorCode::View, |
| 921 | format!("view '{view}' not found"), |
| 922 | )); |
| 923 | } |
| 924 | } |
| 925 | let from_files = repo |
| 926 | .visible_file_paths(from_view) |
| 927 | .map_err(repository_error)?; |
| 928 | let to_files = repo.visible_file_paths(to_view).map_err(repository_error)?; |
| 929 | // Symmetric difference (present on exactly one side) plus the common |
| 930 | // paths whose content actually differs. |
| 931 | let mut all_paths: Vec<String> = from_files |
| 932 | .symmetric_difference(&to_files) |
| 933 | .cloned() |
| 934 | .collect(); |
| 935 | for path in from_files.intersection(&to_files) { |
| 936 | let differs = match ( |
| 937 | repo.get_file_content_on_view(path, from_view), |
| 938 | repo.get_file_content_on_view(path, to_view), |
| 939 | ) { |
| 940 | (Ok(Some(a)), Ok(Some(b))) => a != b, |
| 941 | _ => true, |
| 942 | }; |
| 943 | if differs { |
| 944 | all_paths.push(path.clone()); |
| 945 | } |
| 946 | } |
| 947 | all_paths.sort(); |
| 948 | |
| 949 | let mut chunks = Vec::new(); |
| 950 | for path in all_paths { |
| 951 | let in_from = from_files.contains(&path); |
| 952 | let in_to = to_files.contains(&path); |
| 953 | let status = match (in_from, in_to) { |
| 954 | (true, true) => "modified", |
| 955 | (false, true) => "added", |
| 956 | (true, false) => "deleted", |
| 957 | (false, false) => continue, |
| 958 | }; |
| 959 | let old = repo |
| 960 | .get_file_content_on_view(&path, from_view) |
no test coverage detected