Convert this delta into a `PushDelta`. # Arguments `local_changes` - All changes in the local view that should be considered for upload. The function filters out changes already known to the remote.
(self, local_changes: &[Node])
| 348 | /// considered for upload. The function filters out changes already |
| 349 | /// known to the remote. |
| 350 | pub fn into_push_delta(self, local_changes: &[Node]) -> PushDelta { |
| 351 | let mut delta = PushDelta::new(); |
| 352 | |
| 353 | // Upload local changes that the remote doesn't have. |
| 354 | // A change is "theirs" if it appears in theirs_ge_dichotomy_set. |
| 355 | for node in local_changes { |
| 356 | if !self.theirs_ge_dichotomy_set.contains(node) { |
| 357 | delta |
| 358 | .to_upload |
| 359 | .push(crate::types::Node::change(&node.hash, &node.state)); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | // Unknown changes: things in theirs_ge_dichotomy that aren't in |
| 364 | // our cache (ours_ge_dichotomy) and aren't in our local view. |
| 365 | let local_set: HashSet<&str> = local_changes.iter().map(|n| n.hash.as_str()).collect(); |
| 366 | for (_, node) in &self.theirs_ge_dichotomy { |
| 367 | if !self.ours_ge_dichotomy_set.contains(node) && !local_set.contains(node.hash.as_str()) |
| 368 | { |
| 369 | delta.unknown_changes.push(node.hash.clone()); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // Remote unrecords |
| 374 | for (_, node) in &self.remote_unrecords { |
| 375 | delta.remote_unrecords.push(node.hash.clone()); |
| 376 | } |
| 377 | |
| 378 | delta |
| 379 | } |
| 380 | |
| 381 | /// Check if everything is in sync (no changes to transfer). |
| 382 | pub fn is_in_sync(&self) -> bool { |