MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / has_diverged

Function has_diverged

atomic-cli/tests/fixtures/helpers_c6.rs:137–150  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

135/// }
136/// ```
137pub fn has_diverged(local_entries: &[HistoryEntry], remote_entries: &[ChangelistEntry]) -> bool {
138 // Empty remote can't have diverged
139 if remote_entries.is_empty() {
140 return false;
141 }
142
143 // Build set of local hashes
144 let local_hashes: HashSet<String> = local_entries.iter().map(|e| e.hash.to_base32()).collect();
145
146 // Check if any remote change is not in local
147 remote_entries
148 .iter()
149 .any(|e| !local_hashes.contains(&e.hash))
150}
151
152// Change Data Loading
153

Callers

nothing calls this directly

Calls 5

is_emptyMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
to_base32Method · 0.45
containsMethod · 0.45

Tested by

no test coverage detected