mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-30 10:45:18 -06:00
This patch changes the "Head" of a DataStore to be a single Commit, as opposed to a SetOfCommit. This has several consequences: 1) Commit() will only accept Commits that are descendants of the current Head. 2) Calls to Commit() can now fail, so the method now has an additional 'ok' return value that callers must check. Whether ok is true or false, the DataStore struct returned is the right one to use for subsequent calls to Commit() -- retries or otherwise. 3) This rolls up the stack, so Dataset.Commit() can now fail as well, and similar logic applies. 4) sync.SetNewHeads() also behaves similarly, since it can also now fail. 5) Examples now die on Commit() failures. Also, removes the /dataset endpoint from server. It's deprecated, and this patch would have required updating it, so instead just delete it. Towards issue #147
138 lines
2.8 KiB
Go
138 lines
2.8 KiB
Go
// This file was generated by nomgen.
|
|
// To regenerate, run `go generate` in this package.
|
|
|
|
package datas
|
|
|
|
import (
|
|
"github.com/attic-labs/noms/ref"
|
|
"github.com/attic-labs/noms/types"
|
|
)
|
|
|
|
// SetOfCommit
|
|
|
|
type SetOfCommit struct {
|
|
s types.Set
|
|
}
|
|
|
|
type SetOfCommitIterCallback (func(p Commit) (stop bool))
|
|
|
|
func NewSetOfCommit() SetOfCommit {
|
|
return SetOfCommit{types.NewSet()}
|
|
}
|
|
|
|
func SetOfCommitFromVal(p types.Value) SetOfCommit {
|
|
return SetOfCommit{p.(types.Set)}
|
|
}
|
|
|
|
func (s SetOfCommit) NomsValue() types.Set {
|
|
return s.s
|
|
}
|
|
|
|
func (s SetOfCommit) Equals(p SetOfCommit) bool {
|
|
return s.s.Equals(p.s)
|
|
}
|
|
|
|
func (s SetOfCommit) Ref() ref.Ref {
|
|
return s.s.Ref()
|
|
}
|
|
|
|
func (s SetOfCommit) Empty() bool {
|
|
return s.s.Empty()
|
|
}
|
|
|
|
func (s SetOfCommit) Len() uint64 {
|
|
return s.s.Len()
|
|
}
|
|
|
|
func (s SetOfCommit) Has(p Commit) bool {
|
|
return s.s.Has(p.NomsValue())
|
|
}
|
|
|
|
func (s SetOfCommit) Iter(cb SetOfCommitIterCallback) {
|
|
s.s.Iter(func(v types.Value) bool {
|
|
return cb(CommitFromVal(v))
|
|
})
|
|
}
|
|
|
|
func (s SetOfCommit) Insert(p ...Commit) SetOfCommit {
|
|
return SetOfCommit{s.s.Insert(s.fromElemSlice(p)...)}
|
|
}
|
|
|
|
func (s SetOfCommit) Remove(p ...Commit) SetOfCommit {
|
|
return SetOfCommit{s.s.Remove(s.fromElemSlice(p)...)}
|
|
}
|
|
|
|
func (s SetOfCommit) Union(others ...SetOfCommit) SetOfCommit {
|
|
return SetOfCommit{s.s.Union(s.fromStructSlice(others)...)}
|
|
}
|
|
|
|
func (s SetOfCommit) Subtract(others ...SetOfCommit) SetOfCommit {
|
|
return SetOfCommit{s.s.Subtract(s.fromStructSlice(others)...)}
|
|
}
|
|
|
|
func (s SetOfCommit) Any() Commit {
|
|
return CommitFromVal(s.s.Any())
|
|
}
|
|
|
|
func (s SetOfCommit) fromStructSlice(p []SetOfCommit) []types.Set {
|
|
r := make([]types.Set, len(p))
|
|
for i, v := range p {
|
|
r[i] = v.s
|
|
}
|
|
return r
|
|
}
|
|
|
|
func (s SetOfCommit) fromElemSlice(p []Commit) []types.Value {
|
|
r := make([]types.Value, len(p))
|
|
for i, v := range p {
|
|
r[i] = v.NomsValue()
|
|
}
|
|
return r
|
|
}
|
|
|
|
// Commit
|
|
|
|
type Commit struct {
|
|
m types.Map
|
|
}
|
|
|
|
func NewCommit() Commit {
|
|
return Commit{
|
|
types.NewMap(types.NewString("$name"), types.NewString("Commit")),
|
|
}
|
|
}
|
|
|
|
func CommitFromVal(v types.Value) Commit {
|
|
return Commit{v.(types.Map)}
|
|
}
|
|
|
|
// TODO: This was going to be called Value() but it collides with root.value. We need some other place to put the built-in fields like Value() and Equals().
|
|
func (s Commit) NomsValue() types.Map {
|
|
return s.m
|
|
}
|
|
|
|
func (s Commit) Equals(p Commit) bool {
|
|
return s.m.Equals(p.m)
|
|
}
|
|
|
|
func (s Commit) Ref() ref.Ref {
|
|
return s.m.Ref()
|
|
}
|
|
|
|
func (s Commit) Parents() types.Set {
|
|
return types.SetFromVal(s.m.Get(types.NewString("parents")))
|
|
}
|
|
|
|
func (s Commit) SetParents(p types.Set) Commit {
|
|
return CommitFromVal(s.m.Set(types.NewString("parents"), p))
|
|
}
|
|
|
|
func (s Commit) Value() types.Value {
|
|
return (s.m.Get(types.NewString("value")))
|
|
}
|
|
|
|
func (s Commit) SetValue(p types.Value) Commit {
|
|
return CommitFromVal(s.m.Set(types.NewString("value"), p))
|
|
}
|
|
|