Skip to content

Commit

Permalink
Fixed bug where noop actions were resetting the document version
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Nov 24, 2023
1 parent aded50c commit 4d2538d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/list/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ impl ListBranch {
/// Add everything in merge_frontier into the set..
pub fn merge(&mut self, oplog: &ListOpLog, merge_frontier: &[LV]) {
let mut iter = oplog.get_xf_operations_full(self.version.as_ref(), merge_frontier);
// println!("merge '{}' at {:?} + {:?}", self.content.to_string(), self.version, merge_frontier);

for (_lv, origin_op, xf) in &mut iter {
// dbg!(_lv, &origin_op, &xf);
match (origin_op.kind, xf) {
(ListOpKind::Ins, BaseMoved(pos)) => {
// println!("Insert '{}' at {} (len {})", op.content, ins_pos, op.len());
Expand All @@ -92,8 +94,13 @@ impl ListBranch {
}
}


// dbg!(iter.count_range_tracker_size());

// let expect_v = oplog.cg.graph.find_dominators_2(self.version.as_ref(), merge_frontier);
self.version = iter.into_frontier();
// println!("-> '{}' v {:?}", self.content.to_string(), self.version);
// assert_eq!(self.version, expect_v);
}

}
1 change: 1 addition & 0 deletions src/list/oplog_merge_fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn oplog_merge_fuzz(seed: u64, verbose: bool) {

a.branch.merge(&a.oplog, a.oplog.cg.version.as_ref());
b.branch.merge(&b.oplog, b.oplog.cg.version.as_ref());
// assert_eq!(a.branch.content.to_string(), b.branch.content.to_string());
assert_eq!(a.branch.content, b.branch.content);
}

Expand Down
4 changes: 4 additions & 0 deletions src/list_fuzzer_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const USE_UNICODE: bool = true;

const UCHARS: [char; 23] = [
'a', 'b', 'c', '1', '2', '3', ' ', '\n', // ASCII
// 'd', 'e', 'f',
// 'g', 'h', 'i', 'j',
// 'k', 'l', 'm', 'n',
// 'r', 'q', 'p', 'o',
'©', '¥', '½', // The Latin-1 suppliment (U+80 - U+ff)
'Ύ', 'Δ', 'δ', 'Ϡ', // Greek (U+0370 - U+03FF)
'←', '↯', '↻', '⇈', // Arrows (U+2190 – U+21FF)
Expand Down
3 changes: 3 additions & 0 deletions src/listmerge/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ impl<'a> TransformedOpsIter2<'a> {
from_frontier: &[LV], merge_frontier: &[LV]) -> Self {
let (plan, common) = subgraph.make_m1_plan(from_frontier, merge_frontier);

// println!("From: {:?} / merge: {:?} common {:?}", from_frontier, merge_frontier, common);
// plan.dbg_print();

Self {
subgraph,
aa,
Expand Down
2 changes: 1 addition & 1 deletion src/listmerge2/merge1plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl Graph {
pub(crate) fn make_m1_plan(&self, a: &[LV], b: &[LV]) -> (M1Plan, Frontier) {
if self.frontier_contains_frontier(a, b) {
// Nothing to merge. Do nothing.
return (M1Plan(vec![]), Frontier::root());
return (M1Plan(vec![]), a.into());
}

let mut sg = self.make_conflict_graph_between(a, b);
Expand Down

0 comments on commit 4d2538d

Please sign in to comment.