aboutsummaryrefslogtreecommitdiffstats
path: root/src/remake/delta.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/remake/delta.rs')
-rw-r--r--src/remake/delta.rs33
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::*;