Commit Graph

12 Commits

Author SHA1 Message Date
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