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

Function calculate_pull_delta

atomic-cli/src/commands/pull/helpers.rs:66–100  ·  view source on GitHub ↗

Calculate which changes need to be pulled from the remote. Compares remote and local changelists to determine which remote changes are missing locally. Changes are returned in dependency order (earliest first) so they can be downloaded and applied correctly. # Arguments `remote_entries` - Remote changelist entries (in sequence order) `local_entries` - Local history entries `pull_all` - Whether

(
    remote_entries: &[ChangelistEntry],
    local_entries: &[HistoryEntry],
    pull_all: bool,
)

Source from the content-addressed store, hash-verified

64/// println!("Need to pull {} changes", to_pull.len());
65/// ```
66pub fn calculate_pull_delta(
67 remote_entries: &[ChangelistEntry],
68 local_entries: &[HistoryEntry],
69 pull_all: bool,
70) -> Vec<PullChange> {
71 // Build set of local hashes for quick lookup
72 let local_hashes: HashSet<String> = local_entries.iter().map(|e| e.hash.to_base32()).collect();
73
74 let mut to_download = Vec::new();
75
76 for entry in remote_entries {
77 // Skip if already have this change locally (unless pulling all)
78 if !pull_all && local_hashes.contains(&entry.hash) {
79 continue;
80 }
81
82 // Parse the hash from base32
83 let hash = match Hash::from_base32(entry.hash.as_bytes()) {
84 Some(h) => h,
85 None => continue, // Skip invalid hashes
86 };
87
88 // Parse the merkle state from base32
89 let state = match Merkle::from_base32(entry.merkle.as_bytes()) {
90 Some(m) => m,
91 None => continue, // Skip invalid merkle states
92 };
93
94 let pull_change = PullChange::new(hash, entry.sequence, state).with_tagged(entry.tagged);
95
96 to_download.push(pull_change);
97 }
98
99 to_download
100}
101
102/// Check if there are local-only changes (changes not on the remote).
103///

Calls 7

collectMethod · 0.45
iterMethod · 0.45
to_base32Method · 0.45
containsMethod · 0.45
as_bytesMethod · 0.45
with_taggedMethod · 0.45
pushMethod · 0.45