Commit graph

70 commits

Author SHA1 Message Date
David Pollak
bde0a6fbf6 Cleaned up some warnings and errors running against Rust 1.58.1 2022-02-24 15:20:48 -05:00
alexjg
e72571962b
Correctly sort actor IDs when encoding changes (#241)
The javascript implementation of automerge sorts actor IDs
lexicographically when encoding changes. We were sorting actor IDs in
the order the appear in the change we're encoding. This meant that the
index that we assigned to operations in the encoded change was different
to that which the javascript implementation assigns, resulting in
mismatched head errors as the hashes we created did not match the
javascript implementation.

This change fixes the issue by sorting actor IDs lexicographically. We
make a pass over the operations in the change before encoding to collect
the actor IDs and sort them. This means we no longer need to pass a
mutable `Vec<ActorId>` to the various encode functions, which cleans
things up a little.

Fixes #240
2021-10-17 11:58:15 +01:00
Alex Good
9a421f1f79
Update interop tests to automerge 1.0.1-preview.5
This resulted in one failing test which was due to the pending_changes
we report for a patch being incorrectly calculated from missing
dependencies. I've added a test for this failure and fixed it, interop
tests now pass.
2021-10-14 13:40:16 +01:00
Andrew Jeffery
987263b25d
Add SortedVec struct to ensure preds are sorted (#176)
* Add SortedVec struct to ensure preds are sorted

* Add into_iter for sortedvec
2021-06-19 17:25:25 +01:00
Andrew Jeffery
fc1b8f87fb
Use SmolStr in place of String (#182)
Most of the strings are small and so fit nicely in a SmolStr. When they
don't it just reverts to using a normal String.
2021-06-19 16:28:51 +01:00
Andrew Jeffery
ff8b8613d5
Flatten objtype (#175)
* Flatten object type

* Use separate construct functions

* Use separate gen_*_diff functions

* Remove maptype and seqtype from Diffs

* Preallocate ops in new_map_or_table

* More preallocations
2021-06-17 20:06:10 +01:00
Andrew Jeffery
8b3938c2e7
Rename UncompressedChange to Change (#173)
It wasn't really uncompressed as we have compressed and uncompressed
changes in the backend. It is just not encoded into the binary format.
The module separation (protocol vs backend) should help with the
distinction.
2021-06-16 11:50:26 +01:00
Orion Henry
72d15bfe99 a few things broke in the merge 2021-05-24 16:27:05 -04:00
Vedant Roy
bc249bb630 Fix serialization + add test 2021-05-24 13:17:37 -07:00
Orion Henry
6ebb63bfdd Merge branch 'main' into implement-new-sequence-patch-format 2021-05-24 15:50:19 -04:00
Andrew Jeffery
d5dfefb704
Fix backend panics (#141)
* Fix a panic when indexing the bytes

* Fix leb failing to read enough bytes

* Fix another panic out of bounds

* Use get rather than checking

* Check addition with arbitrary val

* Add backend load fuzzing

* Handle no ops sub

* Fix another index out of bounds
2021-05-20 11:24:23 +01:00
Alex Good
9bbaf7cbd5 Merge branch 'main' into implement-new-sequence-patch-format 2021-05-17 13:03:57 +01:00
Andrew Jeffery
5637956895 Add custom RootDiff type
This ensures that the patch starts with the right diff type statically
and will give an error to js during deserialization.
2021-05-16 14:02:57 +01:00
Andrew Jeffery
2e07e93e72 Change patches diffs to be non-optional 2021-05-16 13:01:37 +01:00
Andrew Jeffery
f2025028cf Fix elem_id in get_patch test 2021-05-15 19:38:11 +01:00
Alex Good
6eb96f2816 Split patch generation out of OpSet 2021-05-14 21:56:24 +01:00
Andrew Jeffery
641fd11703
Change init to new and add defaults (#130)
Structs should use `new` for the constructor name and implement
`Default` where they can.
2021-05-14 21:35:09 +01:00
Andrew Jeffery
f6f874439b
Move decoding to a new module and separate errors (#129) 2021-05-14 20:20:05 +01:00
Alex Good
7ccaae92fd Add test for updates inside conflicted list elements 2021-05-12 23:00:03 +01:00
Andrew Jeffery
5713f4263f Update op id 2021-05-12 16:29:24 +01:00
Andrew Jeffery
9ace8892f6 Remove unchanged diff
Uses empty edits or props instead.
2021-05-11 12:48:45 +01:00
alexjg
e92188104f
Ensure that ChangeBytes::compressed contains the original compressed bytes (#112)
* Ensure that ChangeBytes::compressed contains the original compressed bytes, fixes #95

* Fix clippy

* Move bytes into decompress check

Co-authored-by: Andrew Jeffery <dev@jeffas.io>
2021-05-11 10:33:12 +01:00
Andrew Jeffery
6050f39d46 Change patch diffs to start with mapdiff 2021-05-11 09:26:19 +01:00
Andrew Jeffery
59a24081d2 Switch to expanded_op more 2021-05-10 19:25:43 +01:00
Andrew Jeffery
d794ad4dd5 Update diffedit naming of fields and add comments
This brings the DiffEdit types more in line with the typescript ones and
fixes the names. Also changed to using match guards in the append_edit
function so we can take edit by value.
2021-05-10 13:19:48 +01:00
Andrew Jeffery
708db48fbb Fixup after rebase 2021-05-05 21:58:18 +01:00
Alex Good
e86aabb6a3 Implement new sequence patch format 2021-05-05 21:52:57 +01:00
Andrew Jeffery
d1934f2286 Add formatting config 2021-04-26 09:42:36 -07:00
Andrew Jeffery
aebfdc6572 Update patches with pending_changes 2021-04-24 14:25:31 -07:00
Alex Good
82cf04ae49 Implement compression 2021-03-27 16:52:43 +00:00
Alex Good
c103b0638e Ritual abasement at the altar of clippy 2021-03-02 19:35:00 +00:00
Alex Good
4f4674a4a1 Implement cursors in frontend 2021-03-02 16:07:52 +00:00
Alex Good
26dfc7ea40 Implement cursor logic in backend 2021-02-12 12:03:10 -05:00
Orion Henry
c135b02a48 full document compression 2021-01-29 17:55:59 -05:00
Alex Good
c45d055ce3 Fix clippy 2021-01-16 17:55:30 +00:00
Alex Good
497372db99 Immutable frontend rewrite 2021-01-16 17:40:47 +00:00
Orion Henry
cd6d83ef6d removed an unnecessarry round trip from the change encoder 2021-01-14 14:51:54 -05:00
Alex Good
3c4d64c8a0 Add extra_bytes 2021-01-14 12:30:25 -05:00
Alex Good
3187afcc51 Use more expressive Operation structure 2021-01-14 12:30:25 -05:00
Orion Henry
b6d6b66c06 UncompressedChange moved packages 2021-01-14 12:30:25 -05:00
Alex Good
ce38f5360b Move automerge_backend::UnencodedChange -> automerge_protocol::UncompressedChange 2021-01-14 12:30:25 -05:00
Orion Henry
c1319e06eb patch has a slightly different format now 2020-09-09 12:52:25 -04:00
Alex Good
1ef10f6450 Remove unnecessary in tests 2020-06-04 14:59:19 +01:00
Alex Good
2cf2835e76 Make Patch::clock keys ActorID rather than String 2020-05-30 01:44:00 +01:00
Alex Good
62345c2b5f Make Patch::actor an ActorID, not a string 2020-05-30 01:24:26 +01:00
Alex Good
a36a364443 Rename automerge_protocol::Value -> ScalarValue 2020-05-29 21:04:29 +01:00
Alex Good
b7527c28eb Stop child IDs which are valid object IDs raising MissingObjectError 2020-05-25 19:24:45 +01:00
Alex Good
baaebef6d1 Merge branch 'master' into two-level-objtype 2020-05-25 18:47:46 +01:00
Orion Henry
ab71d01487 internal types impl COPY 2020-05-25 09:43:28 -04:00
Alex Good
2443cdf860 Remove objtype wrapper for diffs 2020-05-24 11:06:23 +01:00