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

Function has_diverged

atomic-cli/tests/fixtures/helpers_c1.rs:123–136  ·  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

121/// }
122/// ```
123pub 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

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