Check if local and remote histories have diverged. Returns true if the remote has changes that are not in the local history. This indicates a conflict that needs to be resolved before pushing. # Arguments `local_entries` - Local history entries `remote_entries` - Remote changelist entries # Returns `true` if the remote has changes not present locally. # Example ```rust,ignore if has_diverge
(local_entries: &[HistoryEntry], remote_entries: &[ChangelistEntry])
| 137 | /// } |
| 138 | /// ``` |
| 139 | pub fn has_diverged(local_entries: &[HistoryEntry], remote_entries: &[ChangelistEntry]) -> bool { |
| 140 | // Empty remote can't have diverged |
| 141 | if remote_entries.is_empty() { |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | // Build set of local hashes |
| 146 | let local_hashes: HashSet<String> = local_entries.iter().map(|e| e.hash.to_base32()).collect(); |
| 147 | |
| 148 | // Check if any remote change is not in local |
| 149 | remote_entries |
| 150 | .iter() |
| 151 | .any(|e| !local_hashes.contains(&e.hash)) |
| 152 | } |
| 153 | |
| 154 | // ============================================================================= |
| 155 | // Change Data Loading |