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

Function calculate_pull_delta

atomic-cli/src/commands/pull/helpers.rs:68–102  ·  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

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

Calls 6

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