mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-01 10:09:41 -06:00
go/store/datas: GetCommitValue -> GetCommittedValue.
This commit is contained in:
@@ -49,7 +49,7 @@ func NewCommit(ctx context.Context, vrw types.ValueReadWriter, commitV types.Val
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rootVal, err := datas.GetCommitValue(ctx, vrw, commitV)
|
||||
rootVal, err := datas.GetCommittedValue(ctx, vrw, commitV)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (s *nomsCommitTestSuite) TestNomsCommitReadPathFromStdin() {
|
||||
vrw := sp.GetVRW(context.Background())
|
||||
commit, ok := sp.GetDataset(context.Background()).MaybeHead()
|
||||
s.True(ok, "should have a commit now")
|
||||
value, err := datas.GetCommitValue(context.Background(), vrw, commit)
|
||||
value, err := datas.GetCommittedValue(context.Background(), vrw, commit)
|
||||
s.NoError(err)
|
||||
s.NotNil(value)
|
||||
h, err := value.Hash(types.Format_7_18)
|
||||
@@ -122,7 +122,7 @@ func (s *nomsCommitTestSuite) TestNomsCommitToDatasetWithoutHead() {
|
||||
vrw := sp.GetVRW(context.Background())
|
||||
commit, ok := sp.GetDataset(context.Background()).MaybeHead()
|
||||
s.True(ok, "should have a commit now")
|
||||
value, err := datas.GetCommitValue(context.Background(), vrw, commit)
|
||||
value, err := datas.GetCommittedValue(context.Background(), vrw, commit)
|
||||
s.NoError(err)
|
||||
s.NotNil(value)
|
||||
h, err := value.Hash(types.Format_7_18)
|
||||
|
||||
@@ -173,7 +173,7 @@ func getMergeCandidates(ctx context.Context, db datas.Database, vrw types.ValueR
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
vfld, err := datas.GetCommitValue(ctx, vrw, ancestorCommit)
|
||||
vfld, err := datas.GetCommittedValue(ctx, vrw, ancestorCommit)
|
||||
d.PanicIfError(err)
|
||||
d.PanicIfFalse(vfld != nil)
|
||||
return leftHead, rightHead, vfld, nil
|
||||
|
||||
@@ -403,11 +403,11 @@ func GetCommitMeta(ctx context.Context, cv types.Value) (*CommitMeta, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetCommitValue(ctx context.Context, vr types.ValueReader, cv types.Value) (types.Value, error) {
|
||||
func GetCommittedValue(ctx context.Context, vr types.ValueReader, cv types.Value) (types.Value, error) {
|
||||
if sm, ok := cv.(types.SerialMessage); ok {
|
||||
data := []byte(sm)
|
||||
if serial.GetFileID(data) != serial.CommitFileID {
|
||||
return nil, errors.New("GetCommitValue: provided value is not a commit.")
|
||||
return nil, errors.New("GetCommittedValue: provided value is not a commit.")
|
||||
}
|
||||
cmsg := serial.GetRootAsCommit(data, 0)
|
||||
var roothash hash.Hash
|
||||
@@ -416,10 +416,10 @@ func GetCommitValue(ctx context.Context, vr types.ValueReader, cv types.Value) (
|
||||
}
|
||||
c, ok := cv.(types.Struct)
|
||||
if !ok {
|
||||
return nil, errors.New("GetCommitValue: provided value is not a commit.")
|
||||
return nil, errors.New("GetCommittedValue: provided value is not a commit.")
|
||||
}
|
||||
if c.Name() != commitName {
|
||||
return nil, errors.New("GetCommitValue: provided value is not a commit.")
|
||||
return nil, errors.New("GetCommittedValue: provided value is not a commit.")
|
||||
}
|
||||
v, _, err := c.MaybeGet(valueField)
|
||||
return v, err
|
||||
|
||||
@@ -326,10 +326,10 @@ func assertCommonAncestor(t *testing.T, expected, a, b types.Value, ldb, rdb *da
|
||||
tv, err := ldb.ReadValue(context.Background(), found)
|
||||
assert.NoError(err)
|
||||
ancestor := tv
|
||||
expV, _ := GetCommitValue(ctx, ldb, expected)
|
||||
aV, _ := GetCommitValue(ctx, ldb, a)
|
||||
bV, _ := GetCommitValue(ctx, rdb, b)
|
||||
ancV, _ := GetCommitValue(ctx, ldb, ancestor)
|
||||
expV, _ := GetCommittedValue(ctx, ldb, expected)
|
||||
aV, _ := GetCommittedValue(ctx, ldb, a)
|
||||
bV, _ := GetCommittedValue(ctx, rdb, b)
|
||||
ancV, _ := GetCommittedValue(ctx, ldb, ancestor)
|
||||
assert.True(
|
||||
expected.Equals(ancestor),
|
||||
"%s should be common ancestor of %s, %s. Got %s",
|
||||
@@ -592,10 +592,10 @@ func TestFindCommonAncestor(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
if !assert.False(ok) {
|
||||
d2V, _ := GetCommitValue(ctx, db, d2)
|
||||
a6V, _ := GetCommitValue(ctx, db, a6)
|
||||
d2V, _ := GetCommittedValue(ctx, db, d2)
|
||||
a6V, _ := GetCommittedValue(ctx, db, a6)
|
||||
fTV, _ := db.ReadValue(ctx, found)
|
||||
fV, _ := GetCommitValue(ctx, db, fTV)
|
||||
fV, _ := GetCommittedValue(ctx, db, fTV)
|
||||
|
||||
assert.Fail(
|
||||
"Unexpected common ancestor!",
|
||||
|
||||
@@ -403,7 +403,7 @@ func (ds Dataset) HasHead() bool {
|
||||
// available. If not it returns nil and 'false'.
|
||||
func (ds Dataset) MaybeHeadValue() (types.Value, bool, error) {
|
||||
if c, ok := ds.MaybeHead(); ok {
|
||||
v, err := GetCommitValue(context.TODO(), ds.db, c)
|
||||
v, err := GetCommittedValue(context.TODO(), ds.db, c)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ func mustGetValue(v types.Value, found bool, err error) types.Value {
|
||||
return v
|
||||
}
|
||||
|
||||
func mustGetCommitValue(db *database, v types.Value) types.Value {
|
||||
r, err := GetCommitValue(context.Background(), db, v)
|
||||
func mustGetCommittedValue(db *database, v types.Value) types.Value {
|
||||
r, err := GetCommittedValue(context.Background(), db, v)
|
||||
d.PanicIfError(err)
|
||||
d.PanicIfFalse(r != nil)
|
||||
return r
|
||||
@@ -67,7 +67,7 @@ func TestExplicitBranchUsingDatasets(t *testing.T) {
|
||||
a := types.String("a")
|
||||
ds1, err = CommitValue(context.Background(), store, ds1, a)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(ds1.db, mustHead(ds1)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(ds1.db, mustHead(ds1)).Equals(a))
|
||||
|
||||
// ds1: |a|
|
||||
// \ds2
|
||||
@@ -75,31 +75,31 @@ func TestExplicitBranchUsingDatasets(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
ds2, err = store.Commit(context.Background(), ds2, mustHeadValue(ds1), CommitOptions{Parents: []hash.Hash{mustHeadAddr(ds1)}})
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(store, mustHead(ds2)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(store, mustHead(ds2)).Equals(a))
|
||||
|
||||
// ds1: |a| <- |b|
|
||||
b := types.String("b")
|
||||
ds1, err = CommitValue(context.Background(), store, ds1, b)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(store, mustHead(ds1)).Equals(b))
|
||||
assert.True(mustGetCommittedValue(store, mustHead(ds1)).Equals(b))
|
||||
|
||||
// ds1: |a| <- |b|
|
||||
// \ds2 <- |c|
|
||||
c := types.String("c")
|
||||
ds2, err = CommitValue(context.Background(), store, ds2, c)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(store, mustHead(ds2)).Equals(c))
|
||||
assert.True(mustGetCommittedValue(store, mustHead(ds2)).Equals(c))
|
||||
|
||||
// ds1: |a| <- |b| <--|d|
|
||||
// \ds2 <- |c| <--/
|
||||
d := types.String("d")
|
||||
ds2, err = store.Commit(context.Background(), ds2, d, CommitOptions{Parents: []hash.Hash{mustHeadAddr(ds1), mustHeadAddr(ds2)}})
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(store, mustHead(ds2)).Equals(d))
|
||||
assert.True(mustGetCommittedValue(store, mustHead(ds2)).Equals(d))
|
||||
|
||||
ds1, err = store.Commit(context.Background(), ds1, d, CommitOptions{Parents: []hash.Hash{mustHeadAddr(ds1), mustHeadAddr(ds2)}})
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(store, mustHead(ds1)).Equals(d))
|
||||
assert.True(mustGetCommittedValue(store, mustHead(ds1)).Equals(d))
|
||||
}
|
||||
|
||||
func TestTwoClientsWithEmptyDataset(t *testing.T) {
|
||||
@@ -118,7 +118,7 @@ func TestTwoClientsWithEmptyDataset(t *testing.T) {
|
||||
a := types.String("a")
|
||||
dsx, err = CommitValue(context.Background(), store, dsx, a)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(dsx.db, mustHead(dsx)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(dsx.db, mustHead(dsx)).Equals(a))
|
||||
|
||||
// dsy: || -> |b|
|
||||
_, ok := dsy.MaybeHead()
|
||||
@@ -151,7 +151,7 @@ func TestTwoClientsWithNonEmptyDataset(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
ds1, err = CommitValue(context.Background(), store, ds1, a)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(ds1.db, mustHead(ds1)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(ds1.db, mustHead(ds1)).Equals(a))
|
||||
}
|
||||
|
||||
dsx, err := store.GetDataset(context.Background(), id1)
|
||||
@@ -160,14 +160,14 @@ func TestTwoClientsWithNonEmptyDataset(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
|
||||
// dsx: |a| -> |b|
|
||||
assert.True(mustGetCommitValue(dsx.db, mustHead(dsx)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(dsx.db, mustHead(dsx)).Equals(a))
|
||||
b := types.String("b")
|
||||
dsx, err = CommitValue(context.Background(), store, dsx, b)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(dsx.db, mustHead(dsx)).Equals(b))
|
||||
assert.True(mustGetCommittedValue(dsx.db, mustHead(dsx)).Equals(b))
|
||||
|
||||
// dsy: |a| -> |c|
|
||||
assert.True(mustGetCommitValue(dsy.db, mustHead(dsy)).Equals(a))
|
||||
assert.True(mustGetCommittedValue(dsy.db, mustHead(dsy)).Equals(a))
|
||||
c := types.String("c")
|
||||
_, err = CommitValue(context.Background(), store, dsy, c)
|
||||
assert.Error(err)
|
||||
@@ -177,7 +177,7 @@ func TestTwoClientsWithNonEmptyDataset(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
dsy, err = CommitValue(context.Background(), store, dsy, c)
|
||||
assert.NoError(err)
|
||||
assert.True(mustGetCommitValue(dsy.db, mustHead(dsy)).Equals(c))
|
||||
assert.True(mustGetCommittedValue(dsy.db, mustHead(dsy)).Equals(c))
|
||||
}
|
||||
|
||||
func TestIdValidation(t *testing.T) {
|
||||
@@ -211,7 +211,7 @@ func TestHeadValueFunctions(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.HasHead())
|
||||
|
||||
hv, err := GetCommitValue(context.Background(), ds1.db, mustHead(ds1))
|
||||
hv, err := GetCommittedValue(context.Background(), ds1.db, mustHead(ds1))
|
||||
assert.NoError(err)
|
||||
assert.Equal(a, hv)
|
||||
assert.Equal(a, mustHeadValue(ds1))
|
||||
|
||||
@@ -181,7 +181,7 @@ func (suite *PullSuite) TestPullEverything() {
|
||||
|
||||
v := mustValue(suite.sinkVRW.ReadValue(context.Background(), sourceAddr)).(types.Struct)
|
||||
suite.NotNil(v)
|
||||
suite.True(l.Equals(mustGetCommitValue(suite.sinkVRW, v)))
|
||||
suite.True(l.Equals(mustGetCommittedValue(suite.sinkVRW, v)))
|
||||
}
|
||||
|
||||
// Source: -6-> C3(L5) -1-> N
|
||||
@@ -228,7 +228,7 @@ func (suite *PullSuite) TestPullMultiGeneration() {
|
||||
v, err := suite.sinkVRW.ReadValue(context.Background(), sourceAddr)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(mustGetCommitValue(suite.sinkVRW, v)))
|
||||
suite.True(srcL.Equals(mustGetCommittedValue(suite.sinkVRW, v)))
|
||||
}
|
||||
|
||||
// Source: -6-> C2(L5) -1-> N
|
||||
@@ -281,7 +281,7 @@ func (suite *PullSuite) TestPullDivergentHistory() {
|
||||
v, err := suite.sinkVRW.ReadValue(context.Background(), sourceAddr)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(mustGetCommitValue(suite.sinkVRW, v)))
|
||||
suite.True(srcL.Equals(mustGetCommittedValue(suite.sinkVRW, v)))
|
||||
}
|
||||
|
||||
// Source: -6-> C2(L4) -1-> N
|
||||
@@ -333,7 +333,7 @@ func (suite *PullSuite) TestPullUpdates() {
|
||||
v, err := suite.sinkVRW.ReadValue(context.Background(), sourceAddr)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(v)
|
||||
suite.True(srcL.Equals(mustGetCommitValue(suite.sinkVRW, v)))
|
||||
suite.True(srcL.Equals(mustGetCommittedValue(suite.sinkVRW, v)))
|
||||
}
|
||||
|
||||
func (suite *PullSuite) commitToSource(v types.Value, p []hash.Hash) hash.Hash {
|
||||
@@ -590,8 +590,8 @@ func mustValue(val types.Value, err error) types.Value {
|
||||
return val
|
||||
}
|
||||
|
||||
func mustGetCommitValue(vr types.ValueReader, c types.Value) types.Value {
|
||||
v, err := datas.GetCommitValue(context.Background(), vr, c)
|
||||
func mustGetCommittedValue(vr types.ValueReader, c types.Value) types.Value {
|
||||
v, err := datas.GetCommittedValue(context.Background(), vr, c)
|
||||
d.PanicIfError(err)
|
||||
d.PanicIfFalse(v != nil)
|
||||
return v
|
||||
|
||||
@@ -46,10 +46,10 @@ func Summary(ctx context.Context, vr1 types.ValueReader, vr2 types.ValueReader,
|
||||
fmt.Println("Comparing commit values")
|
||||
|
||||
var err error
|
||||
value1, err = datas.GetCommitValue(ctx, vr1, value1)
|
||||
value1, err = datas.GetCommittedValue(ctx, vr1, value1)
|
||||
d.PanicIfError(err)
|
||||
|
||||
value2, err = datas.GetCommitValue(ctx, vr2, value2)
|
||||
value2, err = datas.GetCommittedValue(ctx, vr2, value2)
|
||||
d.PanicIfError(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ func TestPinDatasetSpec(t *testing.T) {
|
||||
assert.True(ok)
|
||||
|
||||
commitValue := func(val types.Value) types.Value {
|
||||
v, err := datas.GetCommitValue(context.Background(), vrw, val)
|
||||
v, err := datas.GetCommittedValue(context.Background(), vrw, val)
|
||||
d.PanicIfError(err)
|
||||
d.PanicIfFalse(v != nil)
|
||||
return v
|
||||
|
||||
@@ -175,7 +175,7 @@ func ReadFromReader(ctx context.Context, rd io.Reader) ([]types.Value, error) {
|
||||
return nil, ErrCorruptNVF
|
||||
}
|
||||
|
||||
rootVal, err := datas.GetCommitValue(ctx, vrw, commitSt)
|
||||
rootVal, err := datas.GetCommittedValue(ctx, vrw, commitSt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user