Verify working-copy consistency against the graph. Read-only. See the module docs for the two checks performed. Returns a [`VerifyReport`]; `report.is_healthy()` is `true` when no problems were found.
(
&self,
working_copy: WorkingCopyId,
)
| 103 | /// [`VerifyReport`]; `report.is_healthy()` is `true` when no problems were |
| 104 | /// found. |
| 105 | pub fn verify_working_copy( |
| 106 | &self, |
| 107 | working_copy: WorkingCopyId, |
| 108 | ) -> Result<VerifyReport, RepositoryError> { |
| 109 | self.validate_working_copy(working_copy)?; |
| 110 | let desired_view = self.desired_view_name(working_copy)?; |
| 111 | let mut report = VerifyReport::default(); |
| 112 | |
| 113 | // One status pass classifies every path (Modified/Added/Deleted/ |
| 114 | // Conflicted/Untracked). Clean files are not emitted, so we treat |
| 115 | // "absent from this map" as clean. |
| 116 | let status = self.status(working_copy, StatusOptions::default())?; |
| 117 | let mut status_by_path: HashMap<String, FileStatus> = HashMap::new(); |
| 118 | for e in status.entries() { |
| 119 | status_by_path.insert(e.path().to_string_lossy().to_string(), e.status()); |
| 120 | } |
| 121 | |
| 122 | let listed_conflicts = self.list_conflicts(working_copy)?; |
| 123 | let conflicted: std::collections::HashSet<String> = listed_conflicts |
| 124 | .iter() |
| 125 | .map(|(path, _)| path.clone()) |
| 126 | .collect(); |
| 127 | let name_conflicted: std::collections::HashSet<String> = listed_conflicts |
| 128 | .iter() |
| 129 | .filter(|(_, records)| { |
| 130 | records |
| 131 | .iter() |
| 132 | .any(|record| record.kind == atomic_core::pristine::StoredConflictKind::Name) |
| 133 | }) |
| 134 | .map(|(path, _)| path.clone()) |
| 135 | .collect(); |
| 136 | report.conflicted_files = conflicted.len(); |
| 137 | |
| 138 | // Files visible (tracked + recorded) on the current view. |
| 139 | let visible = self.visible_file_paths(&desired_view)?; |
| 140 | |
| 141 | // Clean files are compared against the graph. Stream them through one |
| 142 | // transaction so the view's span history is decoded once, comparing |
| 143 | // each file as it arrives; only the mismatching lengths are kept and |
| 144 | // reported below in the visible-path order. |
| 145 | let is_uncommitted_or_conflicted = |path: &String| { |
| 146 | matches!( |
| 147 | status_by_path.get(path), |
| 148 | Some(FileStatus::Modified) |
| 149 | | Some(FileStatus::Added) |
| 150 | | Some(FileStatus::Deleted) |
| 151 | | Some(FileStatus::Conflicted) |
| 152 | ) |
| 153 | }; |
| 154 | let clean_paths: Vec<String> = visible |
| 155 | .iter() |
| 156 | .filter(|path| !is_uncommitted_or_conflicted(path)) |
| 157 | .cloned() |
| 158 | .collect(); |
| 159 | let mut drift: HashMap<String, (usize, usize)> = HashMap::new(); |
| 160 | let mut clean_files_checked = 0usize; |
| 161 | self.for_each_file_content_on_view(&clean_paths, &desired_view, |path, graph| { |
| 162 | let disk = std::fs::read(self.root.join(path)).ok(); |
no test coverage detected