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])
| 121 | /// } |
| 122 | /// ``` |
| 123 | pub fn has_diverged(local_entries: &[HistoryEntry], remote_entries: &[ChangelistEntry]) -> bool { |
| 124 | // Empty remote can't have diverged |
| 125 | if remote_entries.is_empty() { |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | // Build set of local hashes |
| 130 | let local_hashes: HashSet<String> = local_entries.iter().map(|e| e.hash.to_base32()).collect(); |
| 131 | |
| 132 | // Check if any remote change is not in local |
| 133 | remote_entries |
| 134 | .iter() |
| 135 | .any(|e| !local_hashes.contains(&e.hash)) |
| 136 | } |
| 137 | |
| 138 | // ============================================================================= |
| 139 | // Change Data Loading |