From be2736890143c7f51167806746cae9eeaf7bf5cf Mon Sep 17 00:00:00 2001 From: Aaron Son Date: Wed, 30 Mar 2022 13:41:20 -0700 Subject: [PATCH] go/store/datas: GetCommitValue -> GetCommittedValue. --- go/libraries/doltcore/doltdb/commit.go | 2 +- go/store/cmd/noms/noms_commit_test.go | 4 ++-- go/store/cmd/noms/noms_merge.go | 2 +- go/store/datas/commit.go | 8 +++---- go/store/datas/commit_test.go | 14 ++++++------ go/store/datas/dataset.go | 2 +- go/store/datas/dataset_test.go | 30 +++++++++++++------------- go/store/datas/pull/pull_test.go | 12 +++++------ go/store/diff/summary.go | 4 ++-- go/store/spec/spec_test.go | 2 +- go/store/valuefile/value_file.go | 2 +- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/go/libraries/doltcore/doltdb/commit.go b/go/libraries/doltcore/doltdb/commit.go index cf4af49e49..6014a20422 100644 --- a/go/libraries/doltcore/doltdb/commit.go +++ b/go/libraries/doltcore/doltdb/commit.go @@ -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 } diff --git a/go/store/cmd/noms/noms_commit_test.go b/go/store/cmd/noms/noms_commit_test.go index 762879da4c..e85253fb4c 100644 --- a/go/store/cmd/noms/noms_commit_test.go +++ b/go/store/cmd/noms/noms_commit_test.go @@ -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) diff --git a/go/store/cmd/noms/noms_merge.go b/go/store/cmd/noms/noms_merge.go index 5271f840ef..f878cdc90f 100644 --- a/go/store/cmd/noms/noms_merge.go +++ b/go/store/cmd/noms/noms_merge.go @@ -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 diff --git a/go/store/datas/commit.go b/go/store/datas/commit.go index 0767764184..ed7e1b6aa3 100644 --- a/go/store/datas/commit.go +++ b/go/store/datas/commit.go @@ -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 diff --git a/go/store/datas/commit_test.go b/go/store/datas/commit_test.go index ceb8a0247e..d0648e5edd 100644 --- a/go/store/datas/commit_test.go +++ b/go/store/datas/commit_test.go @@ -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!", diff --git a/go/store/datas/dataset.go b/go/store/datas/dataset.go index e85c8b3765..785854ecba 100644 --- a/go/store/datas/dataset.go +++ b/go/store/datas/dataset.go @@ -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 } diff --git a/go/store/datas/dataset_test.go b/go/store/datas/dataset_test.go index 40e0975270..99960f1fe7 100644 --- a/go/store/datas/dataset_test.go +++ b/go/store/datas/dataset_test.go @@ -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)) diff --git a/go/store/datas/pull/pull_test.go b/go/store/datas/pull/pull_test.go index 174d27c7fd..6442a1a1f4 100644 --- a/go/store/datas/pull/pull_test.go +++ b/go/store/datas/pull/pull_test.go @@ -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 diff --git a/go/store/diff/summary.go b/go/store/diff/summary.go index aa71e311d2..250e0d08bd 100644 --- a/go/store/diff/summary.go +++ b/go/store/diff/summary.go @@ -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) } } diff --git a/go/store/spec/spec_test.go b/go/store/spec/spec_test.go index 93e5d13abc..76c524a653 100644 --- a/go/store/spec/spec_test.go +++ b/go/store/spec/spec_test.go @@ -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 diff --git a/go/store/valuefile/value_file.go b/go/store/valuefile/value_file.go index b478a49905..e6b41d65a3 100644 --- a/go/store/valuefile/value_file.go +++ b/go/store/valuefile/value_file.go @@ -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 }