Commit Graph

23 Commits

Author SHA1 Message Date
Erik Arvidsson
5ff6432c7b Add support for parsing values (#3688)
This allows parsing all Noms values from the string representation
used by human readable encoding:

```
v, err := nomdl.Parse(vrw, `map {"abc": 42}`)
```

Fixes #1466
2017-09-13 15:02:01 -07:00
Ben Kalman
03b7221c36 Use stretchr/testify not attic-labs/testify (#3677)
stretchr has fixed a bug with the -count flag. I could merge these
changes into attic-labs, but it's easier to just use strechr.

We forked stretchr a long time ago so that we didn't link in the HTTP
testing libraries into the noms binaries (because we were using d.Chk in
production code). The HTTP issue doesn't seem to happen anymore, even
though we're still using d.Chk.
2017-09-07 15:01:03 -07:00
Rafael Weinstein
c3f98d1631 Remove in mem graphs (#3635)
This patch removes the ability to keep alive uncommitted prolly-tree sequences.
2017-08-29 13:12:10 -07:00
Rafael Weinstein
fe0fc3ad86 Introduce SetEditor, Nestable Editors (#3557) 2017-06-21 15:22:04 -07:00
cmasone-attic
16ef8884a7 Make MemoryStore come correct (#3406)
It's important that MemoryStore (and, by extension TestStore)
correctly implement the new ChunkStore semantics before we go
shifting around the Flush semantics like we want to do in #3404

In order to make this a reality, I introduced a "persistence"
layer for MemoryStore called MemoryStorage, which can vend
MemoryStoreView objects that represent a snapshot of the
persistent storage and implement the ChunkStore contract.

Fixes #3400

Removed Rebase() in HandleRootGet, and added ChunkStore
tests to validate the new Put behavior more fully
2017-04-21 14:13:52 -07:00
Erik Arvidsson
fd997f7bfa Add IsValueSubtypeOf and IsCommit (#3375)
This adds IsValueSubtypeOf which skips computing the type of the value.

Use IsValueSubtypeOf to implement IsCommit which checks if a value is a
commit.

Replace usages of IsSubtype(t, TypeOf(v)) with IsValueSubtypeOf(v, t).

Fixes #3326
Fixes #3348
2017-04-13 10:49:17 -07:00
Erik Arvidsson
fd815b10ad Compute type based on value (#3338)
This moves the type off from the value and instead we compute it as we ask for.

This also changes how we detect cycles. If a named struct contains a struct with the
same name we now create a cycle between them. This also means that cycle types
now take a string and not a number.

For encoding we no longer write the type with the value (unless it is a types.Ref).

This is a format change so this takes us to 7.6

Fixes #3328
Fixes #3325
Fixes #3324
Fixes #3323
2017-04-06 17:43:49 -07:00
Erik Arvidsson
c964aff0af Remove types.Value Type() in favor of types.TypeOf() (#3337)
BREAKING CHANGE

This removes the `Type()` method from the `types.Value` interface.
Instead use the `types.TypeOf(v types.Value) bool` function.

Fixes #3324
2017-04-03 14:04:13 -07:00
Erik Arvidsson
d4b412fa1f Rename MakeStructType2 to MakeStructType (#3304)
and remove the old MakeStructType
2017-03-29 15:04:26 -07:00
Erik Arvidsson
2b669edcb3 ToUnresolvedType lost the optional flag (#3301) 2017-03-28 17:40:05 -07:00
Erik Arvidsson
22f70f585d Optional fields (#3287)
This adds optional fields to structs.

New version: 7.4

To create a struct type with optional fields use types.MakeStructType2

There are some API changes in this commit and there will be some more in followup commits.

Fixes #2327
2017-03-27 16:54:04 -07:00
cmasone-attic
e954427903 Go: add heuristic merge option to db.Commit() (#2759)
This patch adds an optional MergePolicy field to CommitOptions. It's a
callback. If the caller sets it, then the commit code will look for a
common ancestor between the Dataset HEAD and the provided Commit. If
the caller-provided Commit descends from HEAD, then Commit proceeds as
normal.
If it does not, but there is a common ancestor, the code runs
merge.ThreeWay() on the values of the provided Commit, HEAD, and the
common ancestor, invoking the MergePolicy callback to resolve
conflicts. If merge succeeds, a merge Commit is created that descends
from both HEAD and the caller-provided Commit. This becomes the new
HEAD of the Dataset.

Fixes #2534
2016-10-27 11:52:46 -07:00
cmasone-attic
2e462b11a5 Make Database a mutable API that vends immutable Datasets (#2617)
Noms SDK users frequently shoot themselves in the foot because they're
holding onto an "old" Database object. That is, they have a Database
tucked away in some internal state, they call Commit() on it, and
don't replace the object in their internal state with the new Database
returned from Commit.

This PR changes the Database and Dataset Go API to be in line with the
proposal in Issue #2589. JS follows in a separate patch.
2016-09-26 12:18:14 -07:00
cmasone-attic
96cc9ffb1c Add FindCommonAncestor for Commits (#2579)
Once we integrate noms-merge into the `noms commit` command, this
function will allow us to stop requiring users to pass in the common
ancestor to be used when merging. The code can just find it and merge
away.

Toward #2535
2016-09-15 16:00:52 -07:00
Eric Halpern
48854dc999 Move datas.descendsFrom and prune search using Ref.Height (#2480)
- Move to commit.CommitDescendsFrom
 - When searching for an ancestor in the commit history, prune
   whenever the commit.Height() < ancestor.Height()
 - Add new test TestCommitDescendsFrom to verify correctness and pruning.
2016-09-02 11:44:38 -07:00
Erik Arvidsson
017d599b1d Fix subtype issue with unions as elem types (#2506)
For compound types (List, Set, Map, Ref) the concrete type may be a
union. If that is the case all the types in the union must be a
subtype of the concrete type's element type.

`C<T | V>` is a subtype of `C<S>` iff T is a subtype of S and V is a
subtype of S.
2016-09-01 18:40:51 -07:00
Mike Gray
4e54c44d56 no functional changes, improving code quality (#2410)
fix misspellings; fix code that was not gofmt'd - plus take advantage of gofmt -s too; couple of unreachable golint reported fixes; reference go report card results and tests
2016-08-23 13:51:38 -04:00
Mike Gray
93916c5139 exposing StructData, updating tour (#2214) 2016-08-01 12:09:02 -04:00
Erik Arvidsson
ff88ff2a65 Commit type: Compute the type for meta too (#2185)
This changes to compute the type for the meta field in a similar
way to how we compute the type for the value field.

Fixes #2179
2016-07-28 17:14:35 -07:00
Erik Arvidsson
68e92092e5 Commit type: Inner parents struct should also have meta
This changes so that all commit struct types have a meta field
(which might be an empty struct).

Increment the serialization version since the old data does not
necessarily have the meta field.

Fixes ##2112
2016-07-21 18:25:17 -07:00
Dan Willhite
4e1bbfcfa5 Simplify basic commit type for validation check 2016-07-21 12:30:36 -07:00
Dan Willhite
137e39d683 Add meta information to commits in cvs-import and url-fetch.
Add "meta" field to commit.
Change noms_log to print meta information when it exists.
Fixes #2012.
2016-07-20 17:18:21 -07:00
Erik Arvidsson
e2f261b142 Go: Compute commit type based on value and parents
We now compute the commit type based on the type of the value and
the type of the parents.

For the first commit we get:

```
struct Commit {
  parents: Set<Ref<Cycle<0>>>,
  value: T,
}
```

As long as we continue to commit values with type T that type stays
the same.

When we later commits a value of type U we get:

```
struct Commit {
  parents: Set<Ref<struct Commit {
    parents: Set<Ref<Cycle<0>>>,
    value: T | U
  }>>,
  value: U,
}
```

The new type gets combined as a union type for the value of the inner
commit struct.

Fixes #1495
2016-07-18 14:28:56 -07:00