diff options
| author | tv <tv@krebsco.de> | 2026-10-31 13:28:55 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 13:28:55 +0100 |
| commit | a3d27a7e20f0279d34bb683782947658c48d8300 (patch) | |
| tree | c7b2e2e23e4fcfd70be75be087119ab3ea21f136 /src/remake/delta.rs | |
| parent | 7ef7e393fa811eb7dd73d025394d21cadc3a2e3a (diff) | |
one function for changed paths
Diffstat (limited to 'src/remake/delta.rs')
| -rw-r--r-- | src/remake/delta.rs | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/src/remake/delta.rs b/src/remake/delta.rs index 80e5443..aebd048 100644 --- a/src/remake/delta.rs +++ b/src/remake/delta.rs @@ -23,12 +23,12 @@ use std::collections::{BTreeMap, HashSet}; -use automerge::{ActorId, AutoCommit, ChangeHash, PatchAction, Prop}; +use automerge::{ActorId, AutoCommit, ChangeHash}; use tracing::warn; use super::kind::{Translation, Translator}; use crate::document::meta::{self, EPOCHS, REMAKES, VOTES}; -use crate::document::store::{self, StoreError}; +use crate::document::store::{self, InLists, StoreError}; #[derive(Debug, Default, Clone)] pub(crate) struct ReplayStats { @@ -229,7 +229,10 @@ pub(crate) fn changed_paths( before: &[ChangeHash], after: &[ChangeHash], ) -> Vec<Vec<String>> { - let mut paths: Vec<Vec<String>> = doc.diff(before, after).iter().map(patch_path).collect(); + let mut paths: Vec<Vec<String>> = store::changed(doc, before, after, InLists::Whole) + .into_iter() + .map(|changed| changed.path) + .collect(); paths.sort(); paths.dedup(); @@ -245,30 +248,6 @@ pub(crate) fn changed_paths( minimal } -fn patch_path(patch: &automerge::Patch) -> Vec<String> { - let mut path = Vec::new(); - for (_, prop) in &patch.path { - match prop { - Prop::Map(key) => path.push(key.clone()), - // Inside a list: the list is replayed as a whole. - Prop::Seq(_) => return path, - } - } - - match &patch.action { - PatchAction::PutMap { key, .. } | PatchAction::DeleteMap { key, .. } => { - path.push(key.clone()) - } - PatchAction::Increment { - prop: Prop::Map(key), - .. - } => path.push(key.clone()), - // List and text edits: the containing object. - _ => {} - } - path -} - #[cfg(test)] mod tests { use super::*; |
