Commit graph

120 commits

Author SHA1 Message Date
Orion Henry
1c61986d33 clippy and fmt 2022-02-24 15:48:48 -05:00
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
5a26f8fcd1 Add missing licenses 2021-09-23 23:41:51 +01:00
Andrew Jeffery
72a79a31d8
Remove default from ActorId (#230)
* Use random as ActorId default

* Remove default for actor

* Use take function on DiffableValue

* Missed the mem::replace
2021-07-29 14:39:30 +01:00
Andrew Jeffery
4ce27ac18b
Use released 1.3.0 of tinyvec (#225) 2021-07-20 15:35:32 +01:00
Andrew Jeffery
9f554252d0
Use tinyvec for actor id (#179)
* Use tinyvec for actor id

Most of the time users will not be using their own identifiers and so
use random uuids. These can fit nicely on the stack for a speedup.
TinyVec allows us to capture this mostly stack, sometimes heap
behaviour.

* Use git version of tinyvec for arbitrary
2021-07-15 10:18:07 +01:00
Andrew Jeffery
94162fc15f
Fix logic for updating changed_indices in diffable sequence (#203)
* Fix logic for updating changed_indices

* Add tests for diffable sequence changed_indices
2021-07-13 12:04:49 +01:00
Andrew Jeffery
78dc394a7a
Fix ambiguous key deserialization (#197) 2021-06-28 18:09:18 +01:00
Orion Henry
3db6f9ef13
Fix Clippy issues, broken tests, formatting issues (#188)
* fix clippy errors

* Bump travis nvm version

* Add smol_str arbitrary

* Fix Err prefix clippy error

* Fix clippy needless-borrow

* Ensure SortedVec sorts on deserialize

Co-authored-by: Andrew Jeffery <dev@jeffas.io>
2021-06-28 13:20:21 +01:00
Vedant Roy
132fa001fc Address review comments 2021-06-25 11:06:25 -07:00
Vedant Roy
ca638691d0 Tests pass after rebase 2021-06-25 11:06:25 -07:00
Vedant Roy
aecfcf2c87 Rebase + clippy 2021-06-25 11:06:25 -07:00
Vedant Roy
bb83460c44 Remove bad file 2021-06-25 11:06:25 -07:00
Vedant Roy
338ec28992 Satisfy clippy 2021-06-25 11:06:25 -07:00
Vedant Roy
14031addd3 Encode Vec<ScalarValue> into type system as ScalarValues 2021-06-25 11:06:25 -07:00
Vedant Roy
9353ae40b2 Remove F32 2021-06-25 11:06:25 -07:00
Vedant Roy
93f45bcc73 Add comment explaining reason for custom serialization 2021-06-25 11:06:25 -07:00
Vedant Roy
0b76f5100c Add custom serialization for DiffEdit 2021-06-25 11:06:25 -07:00
Vedant Roy
c989033365 Add datatype for MultiSet 2021-06-25 11:06:25 -07:00
Orion Henry
6f92d1583d fix error message 2021-06-25 11:06:25 -07:00
Vedant Roy
14bfe9b6b3 Remove unnecessary newline 2021-06-25 11:06:25 -07:00
Vedant Roy
c377b1f491 Properly update field count 2021-06-25 11:06:25 -07:00
Orion Henry
069aa338b2 strict numbers 2021-06-25 11:06:25 -07: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
Andrew Jeffery
a6e955abfd
Rework statetree to be a tree (#156) 2021-06-14 11:08:14 +01:00
Vedant Roy
ae3c3cd563 Avoid return 2021-05-27 17:17:16 -07:00
Vedant Roy
5f7628143d Use return... a bit less 2021-05-27 16:58:16 -07:00
Vedant Roy
f2c0a4953e Report incorrect variant error to serde in RawDiffType::deserialize 2021-05-27 16:54:34 -07:00
Alex Good
623d09d19f Report incorrect variant error to serde in RawOpType::deserialize 2021-05-28 00:40:09 +01:00
Vedant Roy
32f0821e0e Make another enum work with msgpack 2021-05-27 16:33:49 -07:00
Vedant Roy
c845351224 Serialize/Deserialize OpType so it works with msgpack 2021-05-27 15:54:07 -07:00
Vedant Roy
2659efc335 Change outdated error message 2021-05-24 13:17:37 -07:00
Vedant Roy
aaccefcb11 Switch back to using Vec<u8> 2021-05-24 13:17:37 -07:00
Vedant Roy
22af56b059 Internal representation = base64 string 2021-05-24 13:17:37 -07:00
Vedant Roy
41021f398f Add bytes type 2021-05-24 13:17:37 -07:00
Orion Henry
3465517ab3 handle conflicts in list parent modifications 2021-05-24 14:59:09 -04: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
2aa35bc349
Add derive Arbitrary support behind cargo feature (#124) 2021-05-14 16:38:35 +01:00
Andrew Jeffery
9ace8892f6 Remove unchanged diff
Uses empty edits or props instead.
2021-05-11 12:48:45 +01:00
Andrew Jeffery
6050f39d46 Change patch diffs to start with mapdiff 2021-05-11 09:26:19 +01:00
Andrew Jeffery
4caa9798d6 Don't skip props 2021-05-10 23:43:59 +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
9c522cb587 Handle collapsing inserts in edits 2021-05-10 12:27:28 +01:00