From b3a1cf50edf724ec70f0d7913c6c59d82ffd04f3 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 09:15:13 -0700 Subject: [PATCH 01/22] Tidying up tables.go --- go/libraries/doltcore/sqle/tables.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/go/libraries/doltcore/sqle/tables.go b/go/libraries/doltcore/sqle/tables.go index 02d3a015be..1688d9eb0b 100644 --- a/go/libraries/doltcore/sqle/tables.go +++ b/go/libraries/doltcore/sqle/tables.go @@ -73,10 +73,6 @@ func init() { } } -type projected interface { - Project() []string -} - // DoltTable implements the sql.Table interface and gives access to dolt table rows and schema. type DoltTable struct { tableName string @@ -123,7 +119,7 @@ func NewDoltTable(name string, sch schema.Schema, tbl *doltdb.Table, db SqlDatab // LockedToRoot returns a version of this table with its root value locked to the given value. The table's values will // not change as the session's root value changes. Appropriate for AS OF queries, or other use cases where the table's // values should not change throughout execution of a session. -func (t DoltTable) LockedToRoot(ctx *sql.Context, root *doltdb.RootValue) (*DoltTable, error) { +func (t *DoltTable) LockedToRoot(ctx *sql.Context, root *doltdb.RootValue) (*DoltTable, error) { tbl, ok, err := root.GetTable(ctx, t.tableName) if err != nil { return nil, err @@ -175,18 +171,14 @@ type doltReadOnlyTableInterface interface { } var _ doltReadOnlyTableInterface = (*DoltTable)(nil) - -// projected tables disabled for now. Looks like some work needs to be done in the analyzer as there are cases -// where the projected columns do not contain every column needed. Seed this with natural and other joins. There -// may be other cases. -//var _ sql.ProjectedTable = (*DoltTable)(nil) +var _ sql.ProjectedTable = (*DoltTable)(nil) // IndexedAccess implements sql.IndexAddressableTable func (t *DoltTable) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable { return NewIndexedDoltTable(t, lookup.Index.(index.DoltIndex)) } -// doltTable returns the underlying doltTable from the current session +// DoltTable returns the underlying doltTable from the current session func (t *DoltTable) DoltTable(ctx *sql.Context) (*doltdb.Table, error) { root, err := t.workingRoot(ctx) if err != nil { @@ -889,27 +881,27 @@ func (t *DoltTable) GetReferencedForeignKeys(ctx *sql.Context) ([]sql.ForeignKey } // CreateIndexForForeignKey implements sql.ForeignKeyTable -func (t DoltTable) CreateIndexForForeignKey(ctx *sql.Context, idx sql.IndexDef) error { +func (t *DoltTable) CreateIndexForForeignKey(ctx *sql.Context, idx sql.IndexDef) error { return fmt.Errorf("no foreign key operations on a read-only table") } // AddForeignKey implements sql.ForeignKeyTable -func (t DoltTable) AddForeignKey(ctx *sql.Context, fk sql.ForeignKeyConstraint) error { +func (t *DoltTable) AddForeignKey(ctx *sql.Context, fk sql.ForeignKeyConstraint) error { return fmt.Errorf("no foreign key operations on a read-only table") } // DropForeignKey implements sql.ForeignKeyTable -func (t DoltTable) DropForeignKey(ctx *sql.Context, fkName string) error { +func (t *DoltTable) DropForeignKey(ctx *sql.Context, fkName string) error { return fmt.Errorf("no foreign key operations on a read-only table") } // UpdateForeignKey implements sql.ForeignKeyTable -func (t DoltTable) UpdateForeignKey(ctx *sql.Context, fkName string, fk sql.ForeignKeyConstraint) error { +func (t *DoltTable) UpdateForeignKey(ctx *sql.Context, fkName string, fk sql.ForeignKeyConstraint) error { return fmt.Errorf("no foreign key operations on a read-only table") } // GetForeignKeyEditor implements sql.ForeignKeyTable -func (t DoltTable) GetForeignKeyEditor(ctx *sql.Context) sql.ForeignKeyEditor { +func (t *DoltTable) GetForeignKeyEditor(ctx *sql.Context) sql.ForeignKeyEditor { return nil } From 5a2747eb0d8ca44a93d641fb01bf59b34b8e901a Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 11:23:34 -0700 Subject: [PATCH 02/22] Converting ErrSchemaConflict to be a go-errors.v1 instance --- go/libraries/doltcore/merge/merge.go | 2 +- go/libraries/doltcore/merge/merge_rows.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/libraries/doltcore/merge/merge.go b/go/libraries/doltcore/merge/merge.go index 1ff03c7894..a22aa255cd 100644 --- a/go/libraries/doltcore/merge/merge.go +++ b/go/libraries/doltcore/merge/merge.go @@ -29,7 +29,7 @@ import ( var ErrFastForward = errors.New("fast forward") var ErrTableDeletedAndModified = errors.New("conflict: table with same name deleted and modified ") -var ErrSchemaConflict = errors.New("schema conflict found, merge aborted. Please alter schema to prevent schema conflicts before merging") +var ErrSchemaConflict = goerrors.NewKind("schema conflict found, merge aborted. Please alter schema to prevent schema conflicts before merging: %s") // ErrCantOverwriteConflicts is returned when there are unresolved conflicts // and the merge produces new conflicts. Because we currently don't have a model diff --git a/go/libraries/doltcore/merge/merge_rows.go b/go/libraries/doltcore/merge/merge_rows.go index 0f8a6144f6..be68e38813 100644 --- a/go/libraries/doltcore/merge/merge_rows.go +++ b/go/libraries/doltcore/merge/merge_rows.go @@ -128,8 +128,8 @@ func (rm *RootMerger) MergeTable(ctx context.Context, tblName string, opts edito return nil, nil, err } if schConflicts.Count() != 0 { - // error on schema conflicts for now - return nil, nil, fmt.Errorf("%w.\n%s", ErrSchemaConflict, schConflicts.AsError().Error()) + // error on any schema conflicts that we can't resolve + return nil, nil, ErrSchemaConflict.New(schConflicts.AsError().Error()) } if types.IsFormat_DOLT(tm.vrw.Format()) { From 894e80d42df5e4e3b21ca4f6f40307177a2b3bbe Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 11:48:38 -0700 Subject: [PATCH 03/22] Adding schema conflict tests --- .../sqle/enginetest/dolt_queries_merge.go | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go index 0b5f22c328..1dd4ba640a 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries_merge.go @@ -3684,7 +3684,7 @@ var errTmplNoAutomaticMerge = "table %s can't be automatically merged.\nTo merge var ThreeWayMergeWithSchemaChangeTestScripts = []MergeScriptTest{ { - Name: "merge conflicts", + Name: "data conflict", AncSetUpScript: []string{ "set autocommit = 0;", "CREATE table t (pk int primary key, col1 int, col2 varchar(100), col3 varchar(50), " + @@ -4149,6 +4149,45 @@ var ThreeWayMergeWithSchemaChangeTestScripts = []MergeScriptTest{ }, }, + // Schema conflict test cases + { + // https://github.com/dolthub/dolt/issues/2973 + Name: "modifying a column on one side of a merge, and deleting it on the other", + AncSetUpScript: []string{ + "create table t(i int primary key, j int);", + }, + RightSetUpScript: []string{ + "alter table t drop column j;", + }, + LeftSetUpScript: []string{ + "alter table t modify column j varchar(24);", + }, + Assertions: []queries.ScriptTestAssertion{ + { + Query: "call dolt_merge('right');", + ExpectedErr: merge.ErrSchemaConflict, + }, + }, + }, + { + Name: "type changes to a column on both sides of a merge", + AncSetUpScript: []string{ + "create table t(i int primary key, j int);", + }, + RightSetUpScript: []string{ + "alter table t modify column j varchar(100);", + }, + LeftSetUpScript: []string{ + "alter table t modify column j float;", + }, + Assertions: []queries.ScriptTestAssertion{ + { + Query: "call dolt_merge('right');", + ExpectedErr: merge.ErrSchemaConflict, + }, + }, + }, + // Smarter merge conflict detection { // This merge tests reports a conflict on pk=1, because the tuple value is different on the left side, right @@ -4252,7 +4291,6 @@ var ThreeWayMergeWithSchemaChangeTestScripts = []MergeScriptTest{ }, }, { - // TODO: currently panics when merging!!! Name: "changing the type of a column with an index", AncSetUpScript: []string{ "create table t (pk int primary key, col1 int, INDEX col1_idx (col1));", @@ -4271,6 +4309,7 @@ var ThreeWayMergeWithSchemaChangeTestScripts = []MergeScriptTest{ ExpectedErrStr: fmt.Sprintf(errTmplNoAutomaticMerge, "t"), }, { + Skip: true, Query: "select pk, col1 from t order by col1;", Expected: []sql.Row{ {1, "100"}, @@ -4280,7 +4319,6 @@ var ThreeWayMergeWithSchemaChangeTestScripts = []MergeScriptTest{ {5, "50"}, {6, "60"}, }, - Skip: true, }, }, }, From a88ff220d35bdeb90b6e260961982aaa02abefcc Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 12:35:40 -0700 Subject: [PATCH 04/22] First pass on rewriting column merging logic to detect some missing edge cases --- go/libraries/doltcore/merge/merge_schema.go | 337 +++++++++++++++----- 1 file changed, 262 insertions(+), 75 deletions(-) diff --git a/go/libraries/doltcore/merge/merge_schema.go b/go/libraries/doltcore/merge/merge_schema.go index 290c5db511..a532df0afc 100644 --- a/go/libraries/doltcore/merge/merge_schema.go +++ b/go/libraries/doltcore/merge/merge_schema.go @@ -282,105 +282,292 @@ func ForeignKeysMerge(ctx context.Context, mergedRoot, ourRoot, theirRoot, ancRo return common, conflicts, err } -func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (merged *schema.ColCollection, conflicts []ColConflict, err error) { - var common *schema.ColCollection - common, conflicts = columnsInCommon(ourCC, theirCC, ancCC) - - ourNewCols := schema.ColCollectionSetDifference(ourCC, ancCC) - theirNewCols := schema.ColCollectionSetDifference(theirCC, ancCC) - - // check for name conflicts between columns added on each branch since the ancestor - _ = ourNewCols.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) { - theirCol, ok := theirNewCols.GetByNameCaseInsensitive(ourCol.Name) - if ok && ourCol.Tag != theirCol.Tag { - conflicts = append(conflicts, ColConflict{ - Kind: NameCollision, - Ours: ourCol, - Theirs: theirCol, - }) - } - return false, nil - }) - - if len(conflicts) > 0 { - return nil, conflicts, nil - } - - // order of args here is important for correct column ordering in sch schema - // to be before any column in the intersection - // TODO: sch column ordering doesn't respect sql "MODIFY ... AFTER ..." statements - merged, err = schema.ColCollUnion(common, ourNewCols, theirNewCols) +// mergeColumns merges the columns from |ourCC|, |theirCC| into a single column collection, using the ancestor column +// definitions in |ancCC| to determine on which side a column has changed. If merging is not possible because of +// conflicting changes to the columns in |ourCC| and |theirCC|, then a set of ColConflict instances are returned +// describing the conflicts. If any other, unexpected error occurs, then that error is returned and the other response +// fields should be ignored. +// TODO: We don't currently detect all column position changes; the returned merged columns are always based on +// +// their position in |ourCC|, with any new columns from |theirCC| added at the end of the column collection. +func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColCollection, []ColConflict, error) { + columnMappings, err := mapColumns(ourCC, theirCC, ancCC) if err != nil { return nil, nil, err } - return merged, conflicts, nil + conflicts, err := checkSchemaConflicts(columnMappings) + if err != nil { + return nil, nil, err + } + if conflicts != nil { + return nil, conflicts, nil + } + + // After we've checked for schema conflicts, merge the columns together + var mergedColumns []schema.Column + for _, mapping := range columnMappings { + ours := mapping.ours + theirs := mapping.theirs + anc := mapping.anc + + switch { + case ours == nil && theirs != nil: + mergedColumns = append(mergedColumns, *theirs) + case ours != nil && theirs == nil: + mergedColumns = append(mergedColumns, *ours) + case ours == nil && theirs == nil: + // if the column is deleted on both sides... just let it fall out + case ours != nil && theirs != nil: + // otherwise, we have two valid columns and we need to figure out which one to use + if anc != nil { + oursChanged := !anc.Equals(*ours) + theirsChanged := !anc.Equals(*theirs) + if oursChanged && theirsChanged { + // This is a schema change conflict and should have already been caught before this point + return nil, nil, fmt.Errorf("unable to merge conflicting column (%s) "+ + "that changed on both sides of merge", ours.Name) + } else if theirsChanged { + mergedColumns = append(mergedColumns, *theirs) + } else { + mergedColumns = append(mergedColumns, *ours) + } + } else if ours.Equals(*theirs) { + // if the columns are identical, just use ours + mergedColumns = append(mergedColumns, *ours) + } else { + // This is a schema change conflict and should have already been caught before this point + return nil, nil, fmt.Errorf("unable to merge conflicting column (%s) "+ + "that changed on both sides of merge", ours.Name) + } + } + } + + // Check that there are no duplicate column names or tags in the merged column set + conflicts = checkForColumnConflicts(mergedColumns) + if conflicts != nil { + return nil, conflicts, nil + } + + return schema.NewColCollection(mergedColumns...), nil, nil } -func columnsInCommon(ourCC, theirCC, ancCC *schema.ColCollection) (common *schema.ColCollection, conflicts []ColConflict) { - common = schema.NewColCollection() - _ = ourCC.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) { - theirCol, ok := theirCC.GetByTag(ourCol.Tag) - if !ok { - return false, nil - } +// checkForColumnConflicts iterates over |mergedColumns|, checks for duplicate column names or column tags, and returns +// a slice of ColConflicts for any conflicts found. +func checkForColumnConflicts(mergedColumns []schema.Column) []ColConflict { + columnNameSet := map[string]struct{}{} + columnTagSet := map[uint64]struct{}{} + var conflicts []ColConflict - if ourCol.Equals(theirCol) { - common = common.Append(ourCol) - return false, nil + for _, col := range mergedColumns { + if _, ok := columnNameSet[col.Name]; ok { + conflicts = append(conflicts, ColConflict{ + Kind: NameCollision, + Ours: col, + Theirs: col, // TODO: This isn't right... + }) } + columnNameSet[col.Name] = struct{}{} - ancCol, ok := ancCC.GetByTag(ourCol.Tag) - if !ok { - // col added on our branch and their branch with different def + if _, ok := columnTagSet[col.Tag]; ok { conflicts = append(conflicts, ColConflict{ Kind: TagCollision, - Ours: ourCol, - Theirs: theirCol, + Ours: col, + Theirs: col, // TODO: This isn't right... }) - return false, nil } + columnTagSet[col.Tag] = struct{}{} + } - if ancCol.Equals(theirCol) { - // col modified on our branch - col, ok := common.GetByNameCaseInsensitive(ourCol.Name) - if ok { - conflicts = append(conflicts, ColConflict{ - Kind: NameCollision, - Ours: ourCol, - Theirs: col, - }) - } else { - common = common.Append(ourCol) + return conflicts +} + +// checkSchemaConflicts iterates over |columnMappings| and returns any column schema conflicts from column changes +// that can't be automatically merged. +func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) { + var conflicts []ColConflict + for _, mapping := range columnMappings { + ours := mapping.ours + theirs := mapping.theirs + anc := mapping.anc + + // Column exists on our side + if ours != nil { + // If the column is identical on both sides, no need to check any more conflict cases, + // just move on to the next column + if theirs != nil && theirs.Equals(*ours) { + continue } - return false, nil - } - if ancCol.Equals(ourCol) { - // col modified on their branch - col, ok := common.GetByNameCaseInsensitive(theirCol.Name) - if ok { + switch { + case theirs == nil && anc != nil: + // Column doesn't exist on their side, but does exist in ancestor + // This means the column was deleted on theirs side + if !anc.Equals(*ours) { + // col altered on our branch and deleted on their branch + conflicts = append(conflicts, ColConflict{ + // TODO: This probably isn't the right conflict kind to set, but seems like Andy is going to + // rework this anyway, so might not be worth putting much thought into right now. + Kind: ColumnCollision, + Ours: *ours, + }) + } + case theirs != nil && anc != nil: + // Column exists on their side and in ancestor + // If the column differs from the ancestor on both sides, then we have a conflict + if !anc.Equals(*ours) && !anc.Equals(*theirs) { + conflicts = append(conflicts, ColConflict{ + Kind: TagCollision, + Ours: *ours, + Theirs: *theirs, + }) + } + case theirs != nil && anc == nil: + // Column exists on both sides, but not in ancestor + // col added on our branch and their branch with different def + // TODO: Do we have test coverage over this? conflicts = append(conflicts, ColConflict{ - Kind: NameCollision, - Ours: col, - Theirs: theirCol, + Kind: TagCollision, + Ours: *ours, + Theirs: *theirs, }) - } else { - common = common.Append(theirCol) + case theirs == nil && anc == nil: + // just for completeness... if the column is invalid on theirs and in anc, then there is no conflict } - return false, nil } - // col modified on our branch and their branch with different def - conflicts = append(conflicts, ColConflict{ - Kind: TagCollision, - Ours: ourCol, - Theirs: theirCol, - }) + // Column does not exist on our side + if ours == nil { + switch { + case theirs == nil && anc != nil: + // Column doesn't exist on their side and our side, but does exist in ancestor + // deleted on both sides – no conflict + + case theirs != nil && anc != nil: + // Column exists on their side and in ancestor + // If ancs doesn't match theirs, the column was altered on both sides + if !anc.Equals(*theirs) { + // col deleted on our branch and altered on their branch + conflicts = append(conflicts, ColConflict{ + // TODO: This probably isn't the right conflict kind to set, but seems like Andy is going to + // rework this anyway, so might not be worth putting much thought into right now. + Kind: ColumnCollision, + Theirs: *theirs, + //Ours: ours, + }) + } + + case theirs != nil && anc == nil: + // Column exists only on theirs; no conflict + + case theirs == nil && anc == nil: + // Invalid for anc, ours, and theirs should never happen + return nil, fmt.Errorf("invalid column mapping: %v", mapping) + } + } + } + + return conflicts, nil +} + +// columnMapping describes the mapping for a column being merged between the two sides of the merge as well as the ancestor. +type columnMapping struct { + anc *schema.Column + ours *schema.Column + theirs *schema.Column +} + +func newColumnMapping(anc, ours, theirs schema.Column) columnMapping { + var pAnc, pOurs, pTheirs *schema.Column + if anc.Tag != schema.InvalidTag { + pAnc = &anc + } + if ours.Tag != schema.InvalidTag { + pOurs = &ours + } + if theirs.Tag != schema.InvalidTag { + pTheirs = &theirs + } + return columnMapping{pAnc, pOurs, pTheirs} +} + +type columnMappings []columnMapping + +// DebugString returns a string representation of this columnMappings instance. +func (c columnMappings) DebugString() string { + sb := strings.Builder{} + + sb.WriteString("Column Mappings:\n") + for _, mapping := range c { + if mapping.ours != nil { + sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.ours.Name, mapping.ours.Tag)) + } else { + sb.WriteString(" --- ") + } + sb.WriteString(" -> ") + if mapping.theirs != nil { + sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.theirs.Name, mapping.theirs.Tag)) + } else { + sb.WriteString(" --- ") + } + sb.WriteString(" -> ") + if mapping.anc != nil { + sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.anc.Name, mapping.anc.Tag)) + } else { + sb.WriteString(" --- ") + } + sb.WriteString("\n") + } + return sb.String() +} + +// TODO: Test this with some cases where we can't identify the column and see what happens... +// TODO: Godocs +func mapColumns(ourCC, theirCC, ancCC *schema.ColCollection) (columnMappings, error) { + // Make a copy of theirCC so we can modify it to track which their columns we've matched + theirCC = schema.NewColCollection(theirCC.GetColumns()...) + theirTagsToCols := theirCC.TagToCol + + columnMappings := make(columnMappings, 0) + _ = ourCC.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) { + theirCol, foundTheirByTag := theirCC.GetByTag(ourCol.Tag) + if !foundTheirByTag { + // If we didn't find a column on the other side of the merge that exactly matches this tag, then + // we fallback to looking for a match by name + theirCol, _ = theirCC.GetByNameCaseInsensitive(ourCol.Name) + } + + ancCol, foundAncByTag := ancCC.GetByTag(ourCol.Tag) + if !foundAncByTag { + // Ditto for finding the ancestor column + ancCol, _ = ancCC.GetByNameCaseInsensitive(ourCol.Name) + } + + delete(theirTagsToCols, theirCol.Tag) + columnMappings = append(columnMappings, newColumnMapping(ancCol, ourCol, theirCol)) + + // TODO: What if we didn't find a tag match and we didn't find a name match? + // That could mean that there is NOT a mapping! i.e. the column was added or removed + // Or it could mean that the column was renamed and changed its type. In this case, we wouldn't + // be able to match as a rename, so it would just look like a column was added. + // TODO: Potentially in the future, we could look at the column data and calculate if it was logically + // the same column, but this is a heuristic at best. + return false, nil }) - return common, conflicts + // Handle any remaining columns on the "their" side + for _, theirCol := range theirTagsToCols { + ancCol, foundAncByTag := ancCC.GetByTag(theirCol.Tag) + if !foundAncByTag { + // Ditto for finding the ancestor column + ancCol, _ = ancCC.GetByNameCaseInsensitive(theirCol.Name) + } + + columnMappings = append(columnMappings, newColumnMapping(ancCol, schema.InvalidCol, theirCol)) + } + + return columnMappings, nil } // assumes indexes are unique over their column sets From 95e82edc32cf38fb312b81aa5b0f8794f15809f8 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 14:20:27 -0700 Subject: [PATCH 05/22] Fixing failing test --- go/libraries/doltcore/merge/merge_schema.go | 29 +++++++------------ .../doltcore/merge/schema_integration_test.go | 8 ++--- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/go/libraries/doltcore/merge/merge_schema.go b/go/libraries/doltcore/merge/merge_schema.go index a532df0afc..b5c4c1b536 100644 --- a/go/libraries/doltcore/merge/merge_schema.go +++ b/go/libraries/doltcore/merge/merge_schema.go @@ -324,9 +324,7 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle oursChanged := !anc.Equals(*ours) theirsChanged := !anc.Equals(*theirs) if oursChanged && theirsChanged { - // This is a schema change conflict and should have already been caught before this point - return nil, nil, fmt.Errorf("unable to merge conflicting column (%s) "+ - "that changed on both sides of merge", ours.Name) + // This is a schema change conflict and has already been handled by checkSchemaConflicts } else if theirsChanged { mergedColumns = append(mergedColumns, *theirs) } else { @@ -335,16 +333,12 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle } else if ours.Equals(*theirs) { // if the columns are identical, just use ours mergedColumns = append(mergedColumns, *ours) - } else { - // This is a schema change conflict and should have already been caught before this point - return nil, nil, fmt.Errorf("unable to merge conflicting column (%s) "+ - "that changed on both sides of merge", ours.Name) } } } // Check that there are no duplicate column names or tags in the merged column set - conflicts = checkForColumnConflicts(mergedColumns) + conflicts = append(conflicts, checkForColumnConflicts(mergedColumns)...) if conflicts != nil { return nil, conflicts, nil } @@ -355,28 +349,29 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle // checkForColumnConflicts iterates over |mergedColumns|, checks for duplicate column names or column tags, and returns // a slice of ColConflicts for any conflicts found. func checkForColumnConflicts(mergedColumns []schema.Column) []ColConflict { - columnNameSet := map[string]struct{}{} - columnTagSet := map[uint64]struct{}{} + columnNameSet := map[string]schema.Column{} + columnTagSet := map[uint64]schema.Column{} var conflicts []ColConflict for _, col := range mergedColumns { - if _, ok := columnNameSet[col.Name]; ok { + normalizedName := strings.ToLower(col.Name) + if _, ok := columnNameSet[normalizedName]; ok { conflicts = append(conflicts, ColConflict{ Kind: NameCollision, Ours: col, - Theirs: col, // TODO: This isn't right... + Theirs: columnNameSet[normalizedName], }) } - columnNameSet[col.Name] = struct{}{} + columnNameSet[normalizedName] = col if _, ok := columnTagSet[col.Tag]; ok { conflicts = append(conflicts, ColConflict{ Kind: TagCollision, Ours: col, - Theirs: col, // TODO: This isn't right... + Theirs: columnTagSet[col.Tag], }) } - columnTagSet[col.Tag] = struct{}{} + columnTagSet[col.Tag] = col } return conflicts @@ -425,9 +420,8 @@ func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) case theirs != nil && anc == nil: // Column exists on both sides, but not in ancestor // col added on our branch and their branch with different def - // TODO: Do we have test coverage over this? conflicts = append(conflicts, ColConflict{ - Kind: TagCollision, + Kind: NameCollision, // TODO: WHy is this a NameCollision? Ours: *ours, Theirs: *theirs, }) @@ -453,7 +447,6 @@ func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) // rework this anyway, so might not be worth putting much thought into right now. Kind: ColumnCollision, Theirs: *theirs, - //Ours: ours, }) } diff --git a/go/libraries/doltcore/merge/schema_integration_test.go b/go/libraries/doltcore/merge/schema_integration_test.go index 4cbcc22ec8..7e4dc8fff4 100644 --- a/go/libraries/doltcore/merge/schema_integration_test.go +++ b/go/libraries/doltcore/merge/schema_integration_test.go @@ -290,13 +290,13 @@ var mergeSchemaConflictTests = []mergeSchemaConflictTest{ ColConflicts: []merge.ColConflict{ { Kind: merge.NameCollision, - Ours: newColTypeInfo("c4", uint64(4696), typeinfo.Int32Type, false), - Theirs: newColTypeInfo("c4", uint64(8539), typeinfo.Int32Type, false), + Ours: newColTypeInfo("C6", uint64(13258), typeinfo.Int32Type, false), + Theirs: newColTypeInfo("c6", uint64(13258), typeinfo.Int32Type, false), }, { Kind: merge.NameCollision, - Ours: newColTypeInfo("C6", uint64(13258), typeinfo.Int32Type, false), - Theirs: newColTypeInfo("c6", uint64(13258), typeinfo.Int32Type, false), + Ours: newColTypeInfo("c4", uint64(4696), typeinfo.Int32Type, false), + Theirs: newColTypeInfo("c4", uint64(8539), typeinfo.Int32Type, false), }, }, }, From 1a3a2bf2ba7493159eed325bb044dc2e55aa1bf4 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 14:46:59 -0700 Subject: [PATCH 06/22] Fixing failing test for real --- go/libraries/doltcore/merge/merge_schema.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/go/libraries/doltcore/merge/merge_schema.go b/go/libraries/doltcore/merge/merge_schema.go index b5c4c1b536..65be688525 100644 --- a/go/libraries/doltcore/merge/merge_schema.go +++ b/go/libraries/doltcore/merge/merge_schema.go @@ -300,9 +300,6 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle if err != nil { return nil, nil, err } - if conflicts != nil { - return nil, conflicts, nil - } // After we've checked for schema conflicts, merge the columns together var mergedColumns []schema.Column From dc812bc7c81f8920d75448fe066621312cfea325 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Wed, 19 Apr 2023 17:05:15 -0700 Subject: [PATCH 07/22] Bug fix for sql-merge.bats tests --- go/libraries/doltcore/merge/merge_schema.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/go/libraries/doltcore/merge/merge_schema.go b/go/libraries/doltcore/merge/merge_schema.go index 65be688525..3843a554df 100644 --- a/go/libraries/doltcore/merge/merge_schema.go +++ b/go/libraries/doltcore/merge/merge_schema.go @@ -309,9 +309,14 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle anc := mapping.anc switch { - case ours == nil && theirs != nil: + case anc == nil && ours == nil && theirs != nil: + // if an ancestor does not exist, and the column exists only on one side, use that side + // (if an ancestor DOES exist, this means the column was deleted, so it's a no-op) mergedColumns = append(mergedColumns, *theirs) - case ours != nil && theirs == nil: + case anc == nil && ours != nil && theirs == nil: + // if an ancestor does not exist, and the column exists only on one side, use that side + // (if an ancestor DOES exist, this means the column was deleted, so it's a no-op) + // TODO: Can we combine these two cases to make this easier to read? mergedColumns = append(mergedColumns, *ours) case ours == nil && theirs == nil: // if the column is deleted on both sides... just let it fall out From f60e7d04219c5f16de87fa3782dc3c98d6983504 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Thu, 20 Apr 2023 12:07:15 -0700 Subject: [PATCH 08/22] Tidying up before review --- go/libraries/doltcore/merge/merge_schema.go | 39 ++++++++------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/go/libraries/doltcore/merge/merge_schema.go b/go/libraries/doltcore/merge/merge_schema.go index 3843a554df..27ef26b495 100644 --- a/go/libraries/doltcore/merge/merge_schema.go +++ b/go/libraries/doltcore/merge/merge_schema.go @@ -33,7 +33,7 @@ type conflictKind byte const ( TagCollision conflictKind = iota NameCollision - ColumnCollision + ColumnCheckCollision InvalidCheckCollision DeletedCheckCollision ) @@ -104,7 +104,7 @@ func (c ChkConflict) String() string { switch c.Kind { case NameCollision: return fmt.Sprintf("two checks with the name '%s' but different definitions", c.Ours.Name()) - case ColumnCollision: + case ColumnCheckCollision: return fmt.Sprintf("our check '%s' and their check '%s' both reference the same column(s)", c.Ours.Name(), c.Theirs.Name()) case InvalidCheckCollision: return fmt.Sprintf("check '%s' references a column that will be deleted after merge", c.Ours.Name()) @@ -287,9 +287,6 @@ func ForeignKeysMerge(ctx context.Context, mergedRoot, ourRoot, theirRoot, ancRo // conflicting changes to the columns in |ourCC| and |theirCC|, then a set of ColConflict instances are returned // describing the conflicts. If any other, unexpected error occurs, then that error is returned and the other response // fields should be ignored. -// TODO: We don't currently detect all column position changes; the returned merged columns are always based on -// -// their position in |ourCC|, with any new columns from |theirCC| added at the end of the column collection. func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColCollection, []ColConflict, error) { columnMappings, err := mapColumns(ourCC, theirCC, ancCC) if err != nil { @@ -302,6 +299,8 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle } // After we've checked for schema conflicts, merge the columns together + // TODO: We don't currently preserve all column position changes; the returned merged columns are always based on + // their position in |ourCC|, with any new columns from |theirCC| added at the end of the column collection. var mergedColumns []schema.Column for _, mapping := range columnMappings { ours := mapping.ours @@ -316,7 +315,6 @@ func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColColle case anc == nil && ours != nil && theirs == nil: // if an ancestor does not exist, and the column exists only on one side, use that side // (if an ancestor DOES exist, this means the column was deleted, so it's a no-op) - // TODO: Can we combine these two cases to make this easier to read? mergedColumns = append(mergedColumns, *ours) case ours == nil && theirs == nil: // if the column is deleted on both sides... just let it fall out @@ -403,9 +401,7 @@ func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) if !anc.Equals(*ours) { // col altered on our branch and deleted on their branch conflicts = append(conflicts, ColConflict{ - // TODO: This probably isn't the right conflict kind to set, but seems like Andy is going to - // rework this anyway, so might not be worth putting much thought into right now. - Kind: ColumnCollision, + Kind: NameCollision, Ours: *ours, }) } @@ -423,12 +419,12 @@ func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) // Column exists on both sides, but not in ancestor // col added on our branch and their branch with different def conflicts = append(conflicts, ColConflict{ - Kind: NameCollision, // TODO: WHy is this a NameCollision? + Kind: NameCollision, Ours: *ours, Theirs: *theirs, }) case theirs == nil && anc == nil: - // just for completeness... if the column is invalid on theirs and in anc, then there is no conflict + // column doesn't exist on theirs or in anc – no conflict } } @@ -445,9 +441,7 @@ func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) if !anc.Equals(*theirs) { // col deleted on our branch and altered on their branch conflicts = append(conflicts, ColConflict{ - // TODO: This probably isn't the right conflict kind to set, but seems like Andy is going to - // rework this anyway, so might not be worth putting much thought into right now. - Kind: ColumnCollision, + Kind: NameCollision, Theirs: *theirs, }) } @@ -472,6 +466,9 @@ type columnMapping struct { theirs *schema.Column } +// newColumnMapping returns a new columnMapping instance, populated with the specified columns. If |anc|, |ours|, +// or |theirs| is schema.InvalidColumn (checked by looking for schema.InvalidTag), then the returned mapping will +// hold a nil value instead of schema.InvalidColumn. func newColumnMapping(anc, ours, theirs schema.Column) columnMapping { var pAnc, pOurs, pTheirs *schema.Column if anc.Tag != schema.InvalidTag { @@ -516,8 +513,8 @@ func (c columnMappings) DebugString() string { return sb.String() } -// TODO: Test this with some cases where we can't identify the column and see what happens... -// TODO: Godocs +// mapColumns returns a columnMappings instance that describes how the columns in |ourCC|, |theirCC|, and |ancCC| +// map to each other. func mapColumns(ourCC, theirCC, ancCC *schema.ColCollection) (columnMappings, error) { // Make a copy of theirCC so we can modify it to track which their columns we've matched theirCC = schema.NewColCollection(theirCC.GetColumns()...) @@ -540,14 +537,6 @@ func mapColumns(ourCC, theirCC, ancCC *schema.ColCollection) (columnMappings, er delete(theirTagsToCols, theirCol.Tag) columnMappings = append(columnMappings, newColumnMapping(ancCol, ourCol, theirCol)) - - // TODO: What if we didn't find a tag match and we didn't find a name match? - // That could mean that there is NOT a mapping! i.e. the column was added or removed - // Or it could mean that the column was renamed and changed its type. In this case, we wouldn't - // be able to match as a rename, so it would just look like a column was added. - // TODO: Potentially in the future, we could look at the column data and calculate if it was logically - // the same column, but this is a heuristic at best. - return false, nil }) @@ -1021,7 +1010,7 @@ func mergeChecks(ctx context.Context, ourChks, theirChks, ancChks schema.CheckCo if _, ok := theirNewChkColsMap[col][ourChk]; !ok { for k := range theirNewChkColsMap[col] { conflicts = append(conflicts, ChkConflict{ - Kind: ColumnCollision, + Kind: ColumnCheckCollision, Ours: ourChk, Theirs: k, }) From f38ac869e66089661a4c98abdcd9eacabc3ead92 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Thu, 20 Apr 2023 14:25:00 -0700 Subject: [PATCH 09/22] Update ci-check-repo.yaml --- .github/workflows/ci-check-repo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-check-repo.yaml b/.github/workflows/ci-check-repo.yaml index 276e10de7a..7f4e7b266e 100644 --- a/.github/workflows/ci-check-repo.yaml +++ b/.github/workflows/ci-check-repo.yaml @@ -116,7 +116,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref || github.ref }} repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Run go mod tidy run: go mod tidy working-directory: ./go From a6d02445fed1abdcf842f277b42c701a9579fa99 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV <46170177+macneale4@users.noreply.github.com> Date: Thu, 20 Apr 2023 14:54:30 -0700 Subject: [PATCH 10/22] Add the CliContext parameter to Command.Exec (#5779) Related to: https://github.com/dolthub/dolt/issues/3922 --- go/cmd/dolt/cli/cli_context.go | 19 ++++++++++++++++ go/cmd/dolt/cli/command.go | 6 ++--- go/cmd/dolt/cli/command_test.go | 4 ++-- go/cmd/dolt/commands/add.go | 2 +- go/cmd/dolt/commands/admin/setref.go | 2 +- go/cmd/dolt/commands/admin/showroot.go | 2 +- go/cmd/dolt/commands/assist.go | 2 +- go/cmd/dolt/commands/backup.go | 2 +- go/cmd/dolt/commands/blame.go | 4 ++-- go/cmd/dolt/commands/branch.go | 2 +- go/cmd/dolt/commands/checkout.go | 2 +- go/cmd/dolt/commands/cherry-pick.go | 6 ++--- go/cmd/dolt/commands/clean.go | 2 +- go/cmd/dolt/commands/clone.go | 2 +- go/cmd/dolt/commands/cnfcmds/cat.go | 2 +- go/cmd/dolt/commands/cnfcmds/resolve.go | 2 +- go/cmd/dolt/commands/commands_test.go | 2 +- go/cmd/dolt/commands/commit.go | 4 ++-- go/cmd/dolt/commands/config.go | 2 +- go/cmd/dolt/commands/config_test.go | 16 +++++++------- go/cmd/dolt/commands/credcmds/check.go | 2 +- go/cmd/dolt/commands/credcmds/import.go | 2 +- go/cmd/dolt/commands/credcmds/ls.go | 2 +- go/cmd/dolt/commands/credcmds/new.go | 2 +- go/cmd/dolt/commands/credcmds/rm.go | 2 +- go/cmd/dolt/commands/credcmds/use.go | 2 +- .../commands/cvcmds/verify_constraints.go | 2 +- go/cmd/dolt/commands/diff.go | 2 +- go/cmd/dolt/commands/docscmds/diff.go | 2 +- go/cmd/dolt/commands/docscmds/read.go | 2 +- go/cmd/dolt/commands/docscmds/write.go | 2 +- go/cmd/dolt/commands/dump.go | 2 +- go/cmd/dolt/commands/dump_docs.go | 2 +- go/cmd/dolt/commands/fetch.go | 2 +- go/cmd/dolt/commands/filter-branch.go | 2 +- go/cmd/dolt/commands/gc.go | 2 +- go/cmd/dolt/commands/gen_zsh_comp.go | 2 +- go/cmd/dolt/commands/indexcmds/cat.go | 2 +- go/cmd/dolt/commands/indexcmds/ls.go | 2 +- go/cmd/dolt/commands/indexcmds/rebuild.go | 2 +- go/cmd/dolt/commands/init.go | 2 +- go/cmd/dolt/commands/init_test.go | 8 +++---- go/cmd/dolt/commands/inspect.go | 2 +- go/cmd/dolt/commands/log.go | 2 +- go/cmd/dolt/commands/login.go | 2 +- go/cmd/dolt/commands/ls.go | 2 +- go/cmd/dolt/commands/merge.go | 2 +- go/cmd/dolt/commands/merge_base.go | 2 +- go/cmd/dolt/commands/migrate.go | 2 +- go/cmd/dolt/commands/pull.go | 2 +- go/cmd/dolt/commands/push.go | 2 +- go/cmd/dolt/commands/read_tables.go | 2 +- go/cmd/dolt/commands/remote.go | 2 +- go/cmd/dolt/commands/reset.go | 2 +- go/cmd/dolt/commands/revert.go | 6 ++--- go/cmd/dolt/commands/roots.go | 2 +- go/cmd/dolt/commands/schcmds/export.go | 2 +- go/cmd/dolt/commands/schcmds/import.go | 2 +- .../dolt/commands/schcmds/schema_cmd_test.go | 2 +- go/cmd/dolt/commands/schcmds/show.go | 2 +- go/cmd/dolt/commands/schcmds/tags.go | 2 +- go/cmd/dolt/commands/schcmds/update-tag.go | 2 +- go/cmd/dolt/commands/send_metrics.go | 2 +- go/cmd/dolt/commands/show.go | 2 +- go/cmd/dolt/commands/sql.go | 2 +- go/cmd/dolt/commands/sql_test.go | 22 +++++++++---------- go/cmd/dolt/commands/sqlserver/sqlclient.go | 2 +- go/cmd/dolt/commands/sqlserver/sqlserver.go | 2 +- go/cmd/dolt/commands/stashcmds/clear.go | 2 +- go/cmd/dolt/commands/stashcmds/drop.go | 2 +- go/cmd/dolt/commands/stashcmds/list.go | 2 +- go/cmd/dolt/commands/stashcmds/pop.go | 4 ++-- go/cmd/dolt/commands/stashcmds/stash.go | 2 +- go/cmd/dolt/commands/status.go | 2 +- go/cmd/dolt/commands/tag.go | 2 +- go/cmd/dolt/commands/tblcmds/cp.go | 4 ++-- go/cmd/dolt/commands/tblcmds/export.go | 2 +- go/cmd/dolt/commands/tblcmds/import.go | 2 +- go/cmd/dolt/commands/tblcmds/mv.go | 4 ++-- go/cmd/dolt/commands/tblcmds/rm.go | 4 ++-- go/cmd/dolt/commands/version.go | 2 +- go/cmd/dolt/dolt.go | 4 ++-- .../doltcore/doltdb/feature_version_test.go | 2 +- .../doltcore/doltdb/foreign_key_test.go | 10 ++++----- go/libraries/doltcore/doltdb/gc_test.go | 4 ++-- .../merge/keyless_integration_test.go | 8 +++---- .../doltcore/merge/schema_integration_test.go | 14 ++++++------ .../doltcore/migrate/integration_test.go | 2 +- .../doltcore/rebase/filter_branch_test.go | 6 ++--- .../doltcore/schema/integration_test.go | 2 +- .../database_revision_test.go | 2 +- .../integration_test/history_table_test.go | 4 ++-- .../sqle/integration_test/json_value_test.go | 2 +- go/performance/microsysbench/sysbench_test.go | 2 +- 94 files changed, 162 insertions(+), 145 deletions(-) create mode 100644 go/cmd/dolt/cli/cli_context.go diff --git a/go/cmd/dolt/cli/cli_context.go b/go/cmd/dolt/cli/cli_context.go new file mode 100644 index 0000000000..552b9f0de7 --- /dev/null +++ b/go/cmd/dolt/cli/cli_context.go @@ -0,0 +1,19 @@ +// Copyright 2023 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cli + +// CliContexct is used to pass top level command information down to subcommands. +type CliContext interface { +} diff --git a/go/cmd/dolt/cli/command.go b/go/cmd/dolt/cli/command.go index 5667d458c8..03e93e5b3b 100644 --- a/go/cmd/dolt/cli/command.go +++ b/go/cmd/dolt/cli/command.go @@ -64,7 +64,7 @@ type Command interface { // Description returns a description of the command Description() string // Exec executes the command - Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int + Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int // Docs returns the documentation for this command, or nil if it's undocumented Docs() *CommandDocumentation // ArgParser returns the arg parser for this command @@ -169,7 +169,7 @@ func (hc SubCommandHandler) Hidden() bool { return hc.hidden } -func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int { if len(args) < 1 && hc.Unspecified == nil { hc.printUsage(commandStr) return 1 @@ -234,7 +234,7 @@ func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string return 1 } - ret := cmd.Exec(ctx, commandStr, args, dEnv) + ret := cmd.Exec(ctx, commandStr, args, dEnv, nil) if evt != nil { events.GlobalCollector.CloseEventAndAdd(evt) diff --git a/go/cmd/dolt/cli/command_test.go b/go/cmd/dolt/cli/command_test.go index eb2348f79f..10ef5e2912 100644 --- a/go/cmd/dolt/cli/command_test.go +++ b/go/cmd/dolt/cli/command_test.go @@ -68,7 +68,7 @@ func (cmd *trackedCommand) RequiresRepo() bool { return false } -func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int { cmd.called = true cmd.cmdStr = commandStr cmd.args = args @@ -133,7 +133,7 @@ func runCommand(root Command, commandLine string) int { panic("Invalid test command line") } - return root.Exec(context.Background(), appName, tokens[1:], nil) + return root.Exec(context.Background(), appName, tokens[1:], nil, nil) } func TestHasHelpFlag(t *testing.T) { diff --git a/go/cmd/dolt/commands/add.go b/go/cmd/dolt/commands/add.go index d3321bdc83..4942b44614 100644 --- a/go/cmd/dolt/commands/add.go +++ b/go/cmd/dolt/commands/add.go @@ -60,7 +60,7 @@ func (cmd AddCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateAddArgParser() helpPr, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, addDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, helpPr) diff --git a/go/cmd/dolt/commands/admin/setref.go b/go/cmd/dolt/commands/admin/setref.go index cdee6337b0..536fc42f6f 100644 --- a/go/cmd/dolt/commands/admin/setref.go +++ b/go/cmd/dolt/commands/admin/setref.go @@ -64,7 +64,7 @@ func (cmd SetRefCmd) Hidden() bool { // Version displays the version of the running dolt client // Exec executes the command -func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/admin/showroot.go b/go/cmd/dolt/commands/admin/showroot.go index 0ed50e0956..5b8265b87f 100644 --- a/go/cmd/dolt/commands/admin/showroot.go +++ b/go/cmd/dolt/commands/admin/showroot.go @@ -60,7 +60,7 @@ func (cmd ShowRootCmd) Hidden() bool { // Version displays the version of the running dolt client // Exec executes the command -func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/assist.go b/go/cmd/dolt/commands/assist.go index 943d617a00..bd137b2e62 100755 --- a/go/cmd/dolt/commands/assist.go +++ b/go/cmd/dolt/commands/assist.go @@ -66,7 +66,7 @@ func (a Assist) Hidden() bool { return true } -func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { a.messages = make([]string, 0) apiKey, ok := os.LookupEnv("OPENAI_API_KEY") diff --git a/go/cmd/dolt/commands/backup.go b/go/cmd/dolt/commands/backup.go index 18c30069b3..cbc7a22c29 100644 --- a/go/cmd/dolt/commands/backup.go +++ b/go/cmd/dolt/commands/backup.go @@ -105,7 +105,7 @@ func (cmd BackupCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, backupDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/blame.go b/go/cmd/dolt/commands/blame.go index c83611abb4..42373f60a3 100644 --- a/go/cmd/dolt/commands/blame.go +++ b/go/cmd/dolt/commands/blame.go @@ -79,7 +79,7 @@ func (cmd BlameCmd) EventType() eventsapi.ClientEventType { // // When all nodes have blame information, stop iterating through commits and print the blame graph. // Exec executes the command -func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, blameDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -90,5 +90,5 @@ func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, } args = []string{"--" + QueryFlag, fmt.Sprintf(blameQueryTemplate, apr.Arg(0))} - return SqlCmd{}.Exec(ctx, "sql", args, dEnv) + return SqlCmd{}.Exec(ctx, "sql", args, dEnv, nil) } diff --git a/go/cmd/dolt/commands/branch.go b/go/cmd/dolt/commands/branch.go index 1a8290c3cd..c83164b116 100644 --- a/go/cmd/dolt/commands/branch.go +++ b/go/cmd/dolt/commands/branch.go @@ -98,7 +98,7 @@ func (cmd BranchCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, branchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/checkout.go b/go/cmd/dolt/commands/checkout.go index 15cb8472b2..a335d441c8 100644 --- a/go/cmd/dolt/commands/checkout.go +++ b/go/cmd/dolt/commands/checkout.go @@ -78,7 +78,7 @@ func (cmd CheckoutCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateCheckoutArgParser() helpPrt, usagePrt := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkoutDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, helpPrt) diff --git a/go/cmd/dolt/commands/cherry-pick.go b/go/cmd/dolt/commands/cherry-pick.go index 67ff1c598b..c472b71687 100644 --- a/go/cmd/dolt/commands/cherry-pick.go +++ b/go/cmd/dolt/commands/cherry-pick.go @@ -71,7 +71,7 @@ func (cmd CherryPickCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command. -func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateCherryPickArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cherryPickDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -156,13 +156,13 @@ func cherryPick(ctx context.Context, dEnv *env.DoltEnv, cherryStr string) errhan if err != nil { return errhand.VerboseErrorFromError(err) } - res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv) + res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv, nil) if res != 0 { return errhand.BuildDError("dolt add failed").AddCause(err).Build() } commitParams := []string{"-m", commitMsg} - res = CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv) + res = CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv, nil) if res != 0 { return errhand.BuildDError("dolt commit failed").AddCause(err).Build() } diff --git a/go/cmd/dolt/commands/clean.go b/go/cmd/dolt/commands/clean.go index 235ab60da2..172f80f734 100644 --- a/go/cmd/dolt/commands/clean.go +++ b/go/cmd/dolt/commands/clean.go @@ -65,7 +65,7 @@ func (cmd CleanCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateCleanArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cleanDocContent, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/clone.go b/go/cmd/dolt/commands/clone.go index ca0f5c0ba3..c19a870fa8 100644 --- a/go/cmd/dolt/commands/clone.go +++ b/go/cmd/dolt/commands/clone.go @@ -81,7 +81,7 @@ func (cmd CloneCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cloneDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cnfcmds/cat.go b/go/cmd/dolt/commands/cnfcmds/cat.go index 313b7bcd48..c043588ebd 100644 --- a/go/cmd/dolt/commands/cnfcmds/cat.go +++ b/go/cmd/dolt/commands/cnfcmds/cat.go @@ -75,7 +75,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cnfcmds/resolve.go b/go/cmd/dolt/commands/cnfcmds/resolve.go index 43f35b1d55..33c9080a01 100644 --- a/go/cmd/dolt/commands/cnfcmds/resolve.go +++ b/go/cmd/dolt/commands/cnfcmds/resolve.go @@ -88,7 +88,7 @@ func (cmd ResolveCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resDocumentation, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/commands_test.go b/go/cmd/dolt/commands/commands_test.go index 454f8985ff..a41d4dfc49 100644 --- a/go/cmd/dolt/commands/commands_test.go +++ b/go/cmd/dolt/commands/commands_test.go @@ -62,6 +62,6 @@ func TestCommandsRequireInitializedDir(t *testing.T) { dEnv := createUninitializedEnv() for _, test := range tests { - test.comm.Exec(context.Background(), test.cmdStr, test.args, dEnv) + test.comm.Exec(context.Background(), test.cmdStr, test.args, dEnv, nil) } } diff --git a/go/cmd/dolt/commands/commit.go b/go/cmd/dolt/commands/commit.go index cc80302774..cfb26d5c48 100644 --- a/go/cmd/dolt/commands/commit.go +++ b/go/cmd/dolt/commands/commit.go @@ -76,14 +76,14 @@ func (cmd CommitCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { res := performCommit(ctx, commandStr, args, dEnv) if res == 1 { return res } // if the commit was successful, print it out using the log command - return LogCmd{}.Exec(ctx, "log", []string{"-n=1"}, dEnv) + return LogCmd{}.Exec(ctx, "log", []string{"-n=1"}, dEnv, nil) } func performCommit(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { diff --git a/go/cmd/dolt/commands/config.go b/go/cmd/dolt/commands/config.go index 2849b9857e..3a4d9a1776 100644 --- a/go/cmd/dolt/commands/config.go +++ b/go/cmd/dolt/commands/config.go @@ -116,7 +116,7 @@ func (cmd ConfigCmd) ArgParser() *argparser.ArgParser { // Exec is used by the config command to allow users to view / edit their global and repository local configurations. // Exec executes the command -func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cfgDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/config_test.go b/go/cmd/dolt/commands/config_test.go index df5a36643f..b36abc3c4a 100644 --- a/go/cmd/dolt/commands/config_test.go +++ b/go/cmd/dolt/commands/config_test.go @@ -280,8 +280,8 @@ func TestConfig(t *testing.T) { // test setting global config with --add configCmd := ConfigCmd{} - ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "name", "bheni"}, dEnv) - ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "title", "dufus"}, dEnv) + ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "name", "bheni"}, dEnv, nil) + ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "title", "dufus"}, dEnv, nil) expectedGlobal := map[string]string{ "name": "bheni", @@ -295,7 +295,7 @@ func TestConfig(t *testing.T) { } // test setting global config with --set - ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "name", "steph"}, dEnv) + ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "name", "steph"}, dEnv, nil) expectedGlobal = map[string]string{ "name": "steph", @@ -309,7 +309,7 @@ func TestConfig(t *testing.T) { } // test setting local config with --add - ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "title", "senior dufus"}, dEnv) + ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "title", "senior dufus"}, dEnv, nil) expectedLocal := map[string]string{ "title": "senior dufus", @@ -324,7 +324,7 @@ func TestConfig(t *testing.T) { } // test setting local config with --set - ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "name", "steph"}, dEnv) + ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "name", "steph"}, dEnv, nil) expectedLocal = map[string]string{ "name": "steph", @@ -339,7 +339,7 @@ func TestConfig(t *testing.T) { t.Error("Unexpected value of \"name\" retrieved from the config hierarchy") } - ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "name"}, dEnv) + ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "name"}, dEnv, nil) expectedGlobal = map[string]string{ "title": "dufus", @@ -402,14 +402,14 @@ func TestInvalidConfigArgs(t *testing.T) { configCmd := ConfigCmd{} // local and global flags passed together is invalid - ret := configCmd.Exec(ctx, "dolt config", []string{"--global", "--local", "--add", "name", "bheni"}, dEnv) + ret := configCmd.Exec(ctx, "dolt config", []string{"--global", "--local", "--add", "name", "bheni"}, dEnv, nil) if ret == 0 { t.Error("Invalid commands should fail. Command has both local and global") } // both -add and -get are used - ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--get", "--add", "title"}, dEnv) + ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--get", "--add", "title"}, dEnv, nil) if ret == 0 { t.Error("Invalid commands should fail. Command is missing local/global") diff --git a/go/cmd/dolt/commands/credcmds/check.go b/go/cmd/dolt/commands/credcmds/check.go index 53e0588879..2c05aaf47b 100644 --- a/go/cmd/dolt/commands/credcmds/check.go +++ b/go/cmd/dolt/commands/credcmds/check.go @@ -78,7 +78,7 @@ func (cmd CheckCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/import.go b/go/cmd/dolt/commands/credcmds/import.go index 7f2995d616..e56b02f8c3 100644 --- a/go/cmd/dolt/commands/credcmds/import.go +++ b/go/cmd/dolt/commands/credcmds/import.go @@ -89,7 +89,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/ls.go b/go/cmd/dolt/commands/credcmds/ls.go index 2a555323ef..a0768de9b0 100644 --- a/go/cmd/dolt/commands/credcmds/ls.go +++ b/go/cmd/dolt/commands/credcmds/ls.go @@ -74,7 +74,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/new.go b/go/cmd/dolt/commands/credcmds/new.go index 75f8e9082a..1950562bbc 100644 --- a/go/cmd/dolt/commands/credcmds/new.go +++ b/go/cmd/dolt/commands/credcmds/new.go @@ -70,7 +70,7 @@ func (cmd NewCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, newDocs, ap)) cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/rm.go b/go/cmd/dolt/commands/credcmds/rm.go index bbc7a1be6f..66da291dad 100644 --- a/go/cmd/dolt/commands/credcmds/rm.go +++ b/go/cmd/dolt/commands/credcmds/rm.go @@ -67,7 +67,7 @@ func (cmd RmCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rmDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/use.go b/go/cmd/dolt/commands/credcmds/use.go index dcbc3baaa8..1648f2167a 100644 --- a/go/cmd/dolt/commands/credcmds/use.go +++ b/go/cmd/dolt/commands/credcmds/use.go @@ -73,7 +73,7 @@ func (cmd UseCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, useDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cvcmds/verify_constraints.go b/go/cmd/dolt/commands/cvcmds/verify_constraints.go index 0e72b1ee0d..0b437785b1 100644 --- a/go/cmd/dolt/commands/cvcmds/verify_constraints.go +++ b/go/cmd/dolt/commands/cvcmds/verify_constraints.go @@ -67,7 +67,7 @@ func (cmd VerifyConstraintsCmd) ArgParser() *argparser.ArgParser { return cli.CreateVerifyConstraintsArgParser(cmd.Name()) } -func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, verifyConstraintsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/diff.go b/go/cmd/dolt/commands/diff.go index caf1e1967f..920251ad24 100644 --- a/go/cmd/dolt/commands/diff.go +++ b/go/cmd/dolt/commands/diff.go @@ -159,7 +159,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/diff.go b/go/cmd/dolt/commands/docscmds/diff.go index 221b17fd56..8b47031dc1 100644 --- a/go/cmd/dolt/commands/docscmds/diff.go +++ b/go/cmd/dolt/commands/docscmds/diff.go @@ -66,7 +66,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/read.go b/go/cmd/dolt/commands/docscmds/read.go index 1df307b357..c6ec28ec98 100644 --- a/go/cmd/dolt/commands/docscmds/read.go +++ b/go/cmd/dolt/commands/docscmds/read.go @@ -71,7 +71,7 @@ func (cmd UploadCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, uploadDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/write.go b/go/cmd/dolt/commands/docscmds/write.go index 6594ea52a9..b4f2634a87 100644 --- a/go/cmd/dolt/commands/docscmds/write.go +++ b/go/cmd/dolt/commands/docscmds/write.go @@ -69,7 +69,7 @@ func (cmd PrintCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, printDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/dump.go b/go/cmd/dolt/commands/dump.go index 70d6e458d8..cbf9fc39c9 100644 --- a/go/cmd/dolt/commands/dump.go +++ b/go/cmd/dolt/commands/dump.go @@ -113,7 +113,7 @@ func (cmd DumpCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, dumpDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/dump_docs.go b/go/cmd/dolt/commands/dump_docs.go index a5493d2a46..c34497b7fe 100644 --- a/go/cmd/dolt/commands/dump_docs.go +++ b/go/cmd/dolt/commands/dump_docs.go @@ -72,7 +72,7 @@ func (cmd *DumpDocsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/fetch.go b/go/cmd/dolt/commands/fetch.go index 30843fd597..e6090e39cf 100644 --- a/go/cmd/dolt/commands/fetch.go +++ b/go/cmd/dolt/commands/fetch.go @@ -68,7 +68,7 @@ func (cmd FetchCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateFetchArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, fetchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/filter-branch.go b/go/cmd/dolt/commands/filter-branch.go index 2524eb2bb4..fc4d619de3 100644 --- a/go/cmd/dolt/commands/filter-branch.go +++ b/go/cmd/dolt/commands/filter-branch.go @@ -96,7 +96,7 @@ func (cmd FilterBranchCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, filterBranchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/gc.go b/go/cmd/dolt/commands/gc.go index 873f3aa95a..0187135b9b 100644 --- a/go/cmd/dolt/commands/gc.go +++ b/go/cmd/dolt/commands/gc.go @@ -81,7 +81,7 @@ func (cmd GarbageCollectionCmd) EventType() eventsapi.ClientEventType { // Version displays the version of the running dolt client // Exec executes the command -func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { var verr errhand.VerboseError ap := cmd.ArgParser() diff --git a/go/cmd/dolt/commands/gen_zsh_comp.go b/go/cmd/dolt/commands/gen_zsh_comp.go index 0085c5d5a4..e6d4e6aefc 100755 --- a/go/cmd/dolt/commands/gen_zsh_comp.go +++ b/go/cmd/dolt/commands/gen_zsh_comp.go @@ -47,7 +47,7 @@ func (z GenZshCompCmd) Description() string { return "Creates a zsh autocomp file for all dolt commands" } -func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := z.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/indexcmds/cat.go b/go/cmd/dolt/commands/indexcmds/cat.go index 275510cf4d..c23078490a 100644 --- a/go/cmd/dolt/commands/indexcmds/cat.go +++ b/go/cmd/dolt/commands/indexcmds/cat.go @@ -79,7 +79,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/indexcmds/ls.go b/go/cmd/dolt/commands/indexcmds/ls.go index 1560e24d43..c19a684d38 100644 --- a/go/cmd/dolt/commands/indexcmds/ls.go +++ b/go/cmd/dolt/commands/indexcmds/ls.go @@ -55,7 +55,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() ap.TooManyArgsErrorFunc = func(receivedArgs []string) error { args := strings.Join(receivedArgs, ", ") diff --git a/go/cmd/dolt/commands/indexcmds/rebuild.go b/go/cmd/dolt/commands/indexcmds/rebuild.go index 7a632dc5b2..fe50050d69 100644 --- a/go/cmd/dolt/commands/indexcmds/rebuild.go +++ b/go/cmd/dolt/commands/indexcmds/rebuild.go @@ -58,7 +58,7 @@ func (cmd RebuildCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rebuildDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/init.go b/go/cmd/dolt/commands/init.go index d1d9e031b4..903dffa6ff 100644 --- a/go/cmd/dolt/commands/init.go +++ b/go/cmd/dolt/commands/init.go @@ -86,7 +86,7 @@ func (cmd InitCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/init_test.go b/go/cmd/dolt/commands/init_test.go index e615d44723..b70da9685e 100644 --- a/go/cmd/dolt/commands/init_test.go +++ b/go/cmd/dolt/commands/init_test.go @@ -67,7 +67,7 @@ func TestInit(t *testing.T) { gCfg, _ := dEnv.Config.GetConfig(env.GlobalConfig) gCfg.SetStrings(test.GlobalConfig) - result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv) + result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv, nil) defer dEnv.DoltDB.Close() require.Equalf(t, test.ExpectSuccess, result == 0, "- Expected success: %t; result: %t;", test.ExpectSuccess, result == 0) @@ -86,13 +86,11 @@ func TestInit(t *testing.T) { func TestInitTwice(t *testing.T) { dEnv := createUninitializedEnv() - result := InitCmd{}.Exec(context.Background(), "dolt init", - []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv) + result := InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv, nil) require.True(t, result == 0, "First init should succeed") defer dEnv.DoltDB.Close() - result = InitCmd{}.Exec(context.Background(), "dolt init", - []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv) + result = InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv, nil) require.True(t, result != 0, "Second init should fail") } diff --git a/go/cmd/dolt/commands/inspect.go b/go/cmd/dolt/commands/inspect.go index 169ab083c2..1a0c627eea 100644 --- a/go/cmd/dolt/commands/inspect.go +++ b/go/cmd/dolt/commands/inspect.go @@ -73,7 +73,7 @@ func (cmd InspectCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/log.go b/go/cmd/dolt/commands/log.go index 6bbf5e5184..2af8db6537 100644 --- a/go/cmd/dolt/commands/log.go +++ b/go/cmd/dolt/commands/log.go @@ -109,7 +109,7 @@ func (cmd LogCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { return cmd.logWithLoggerFunc(ctx, commandStr, args, dEnv) } diff --git a/go/cmd/dolt/commands/login.go b/go/cmd/dolt/commands/login.go index 3db37e25dd..afb08bf406 100644 --- a/go/cmd/dolt/commands/login.go +++ b/go/cmd/dolt/commands/login.go @@ -94,7 +94,7 @@ func (cmd LoginCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, loginDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/ls.go b/go/cmd/dolt/commands/ls.go index df7bbecb40..15849cabc0 100644 --- a/go/cmd/dolt/commands/ls.go +++ b/go/cmd/dolt/commands/ls.go @@ -78,7 +78,7 @@ func (cmd LsCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/merge.go b/go/cmd/dolt/commands/merge.go index 26215e9f6e..8ca6d7a146 100644 --- a/go/cmd/dolt/commands/merge.go +++ b/go/cmd/dolt/commands/merge.go @@ -77,7 +77,7 @@ func (cmd MergeCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateMergeArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/merge_base.go b/go/cmd/dolt/commands/merge_base.go index 083666f259..3b84ab0da0 100644 --- a/go/cmd/dolt/commands/merge_base.go +++ b/go/cmd/dolt/commands/merge_base.go @@ -65,7 +65,7 @@ func (cmd MergeBaseCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeBaseDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/migrate.go b/go/cmd/dolt/commands/migrate.go index 5c6cc2c675..07c2a7e1a9 100644 --- a/go/cmd/dolt/commands/migrate.go +++ b/go/cmd/dolt/commands/migrate.go @@ -75,7 +75,7 @@ func (cmd MigrateCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, migrateDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/pull.go b/go/cmd/dolt/commands/pull.go index ea432eb5c7..1278120e8b 100644 --- a/go/cmd/dolt/commands/pull.go +++ b/go/cmd/dolt/commands/pull.go @@ -68,7 +68,7 @@ func (cmd PullCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreatePullArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pullDocs, ap)) diff --git a/go/cmd/dolt/commands/push.go b/go/cmd/dolt/commands/push.go index d5a6fa9036..b13fd34110 100644 --- a/go/cmd/dolt/commands/push.go +++ b/go/cmd/dolt/commands/push.go @@ -80,7 +80,7 @@ func (cmd PushCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pushDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/read_tables.go b/go/cmd/dolt/commands/read_tables.go index 2e5d7476c5..acb9b87e78 100644 --- a/go/cmd/dolt/commands/read_tables.go +++ b/go/cmd/dolt/commands/read_tables.go @@ -84,7 +84,7 @@ func (cmd ReadTablesCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, readTablesDocs, ap)) diff --git a/go/cmd/dolt/commands/remote.go b/go/cmd/dolt/commands/remote.go index e9c6ecaff1..7619e24c09 100644 --- a/go/cmd/dolt/commands/remote.go +++ b/go/cmd/dolt/commands/remote.go @@ -101,7 +101,7 @@ func (cmd RemoteCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, remoteDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/reset.go b/go/cmd/dolt/commands/reset.go index 9bedc34ab1..29176ddb9a 100644 --- a/go/cmd/dolt/commands/reset.go +++ b/go/cmd/dolt/commands/reset.go @@ -81,7 +81,7 @@ func (cmd ResetCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateResetArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resetDocContent, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/revert.go b/go/cmd/dolt/commands/revert.go index 5173c07bc0..bfe1479a31 100644 --- a/go/cmd/dolt/commands/revert.go +++ b/go/cmd/dolt/commands/revert.go @@ -64,7 +64,7 @@ func (cmd RevertCmd) ArgParser() *argparser.ArgParser { } // Exec implements the interface cli.Command. -func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateRevertArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, revertDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -144,7 +144,7 @@ func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, if err != nil { return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage) } - res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv) + res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv, nil) if res != 0 { return res } @@ -156,5 +156,5 @@ func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, commitParams = append(commitParams, "--author", authorStr) } - return CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv) + return CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv, nil) } diff --git a/go/cmd/dolt/commands/roots.go b/go/cmd/dolt/commands/roots.go index 9115686a5e..8586bc964f 100644 --- a/go/cmd/dolt/commands/roots.go +++ b/go/cmd/dolt/commands/roots.go @@ -80,7 +80,7 @@ func (cmd RootsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/export.go b/go/cmd/dolt/commands/schcmds/export.go index 5ae8b1e29a..37cc8b8725 100644 --- a/go/cmd/dolt/commands/schcmds/export.go +++ b/go/cmd/dolt/commands/schcmds/export.go @@ -74,7 +74,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schExportDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/import.go b/go/cmd/dolt/commands/schcmds/import.go index 38e1e90ec1..ac6aadf5cf 100644 --- a/go/cmd/dolt/commands/schcmds/import.go +++ b/go/cmd/dolt/commands/schcmds/import.go @@ -160,7 +160,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser { // Exec implements the import schema command that will take a file and infer it's schema, and then create a table matching that schema. // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schImportDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/schema_cmd_test.go b/go/cmd/dolt/commands/schcmds/schema_cmd_test.go index 963afa13eb..a007e6c94e 100644 --- a/go/cmd/dolt/commands/schcmds/schema_cmd_test.go +++ b/go/cmd/dolt/commands/schcmds/schema_cmd_test.go @@ -33,6 +33,6 @@ func TestSchemaExport(t *testing.T) { args := []string{} commandStr := "dolt schema export" - result := ExportCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := ExportCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, 0, result) } diff --git a/go/cmd/dolt/commands/schcmds/show.go b/go/cmd/dolt/commands/schcmds/show.go index 827d564833..c67430dea5 100644 --- a/go/cmd/dolt/commands/schcmds/show.go +++ b/go/cmd/dolt/commands/schcmds/show.go @@ -73,7 +73,7 @@ func (cmd ShowCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblSchemaDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/tags.go b/go/cmd/dolt/commands/schcmds/tags.go index 43d92b6c69..5d7001beb3 100644 --- a/go/cmd/dolt/commands/schcmds/tags.go +++ b/go/cmd/dolt/commands/schcmds/tags.go @@ -64,7 +64,7 @@ func (cmd TagsCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblTagsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/update-tag.go b/go/cmd/dolt/commands/schcmds/update-tag.go index b71153c79e..c9408bdcc7 100644 --- a/go/cmd/dolt/commands/schcmds/update-tag.go +++ b/go/cmd/dolt/commands/schcmds/update-tag.go @@ -65,7 +65,7 @@ func (cmd UpdateTagCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, updateTagDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/send_metrics.go b/go/cmd/dolt/commands/send_metrics.go index 3b3db85d18..8047854f58 100644 --- a/go/cmd/dolt/commands/send_metrics.go +++ b/go/cmd/dolt/commands/send_metrics.go @@ -74,7 +74,7 @@ func (cmd SendMetricsCmd) ArgParser() *argparser.ArgParser { // Exec is the implementation of the command that flushes the events to the grpc service // Exec executes the command -func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if dEnv.DoltDB != nil { // see go/cmd/dolt/dolt.go:interceptSendMetrics() cli.PrintErrln("expected DoltEnv without DoltDB") return 1 diff --git a/go/cmd/dolt/commands/show.go b/go/cmd/dolt/commands/show.go index 9e1c54a761..12d1a6ee0a 100644 --- a/go/cmd/dolt/commands/show.go +++ b/go/cmd/dolt/commands/show.go @@ -90,7 +90,7 @@ func (cmd ShowCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, showDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/sql.go b/go/cmd/dolt/commands/sql.go index 024d143fcf..8e65c53ca9 100644 --- a/go/cmd/dolt/commands/sql.go +++ b/go/cmd/dolt/commands/sql.go @@ -179,7 +179,7 @@ func (cmd SqlCmd) RequiresRepo() bool { // Exec executes the command // Unlike other commands, sql doesn't set a new working root directly, as the SQL layer updates the working set as // necessary when committing work. -func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlDocs, ap)) diff --git a/go/cmd/dolt/commands/sql_test.go b/go/cmd/dolt/commands/sql_test.go index d65f15c0b0..f8e1138fb3 100644 --- a/go/cmd/dolt/commands/sql_test.go +++ b/go/cmd/dolt/commands/sql_test.go @@ -53,7 +53,7 @@ func TestSqlConsole(t *testing.T) { args := []string{} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, 0, result) }) @@ -81,7 +81,7 @@ func TestSqlBatchMode(t *testing.T) { args := []string{"-b", "-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -120,7 +120,7 @@ func TestSqlSelect(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -146,7 +146,7 @@ func TestSqlShow(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -179,7 +179,7 @@ func TestCreateTable(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) working, err = dEnv.WorkingRoot(context.Background()) @@ -219,7 +219,7 @@ func TestShowTables(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -250,7 +250,7 @@ func TestAlterTable(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -277,7 +277,7 @@ func TestDropTable(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv) + result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) }) } @@ -396,7 +396,7 @@ func TestInsert(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv) + result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) if result == 0 { @@ -477,7 +477,7 @@ func TestUpdate(t *testing.T) { args := []string{"-q", test.query} commandStr := "dolt sql" - result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv) + result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) if result == 0 { @@ -552,7 +552,7 @@ func TestDelete(t *testing.T) { ctx := context.Background() commandStr := "dolt sql" - result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv) + result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil) assert.Equal(t, test.expectedRes, result) if result == 0 { diff --git a/go/cmd/dolt/commands/sqlserver/sqlclient.go b/go/cmd/dolt/commands/sqlserver/sqlclient.go index 8bca8a33ee..89853ff06c 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlclient.go +++ b/go/cmd/dolt/commands/sqlserver/sqlclient.go @@ -99,7 +99,7 @@ func (cmd SqlClientCmd) Hidden() bool { return false } -func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlClientDocs, ap)) diff --git a/go/cmd/dolt/commands/sqlserver/sqlserver.go b/go/cmd/dolt/commands/sqlserver/sqlserver.go index e8c02ced9f..86688c8bb7 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlserver.go +++ b/go/cmd/dolt/commands/sqlserver/sqlserver.go @@ -173,7 +173,7 @@ func (cmd SqlServerCmd) RequiresRepo() bool { } // Exec executes the command -func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { controller := NewServerController() newCtx, cancelF := context.WithCancel(context.Background()) go func() { diff --git a/go/cmd/dolt/commands/stashcmds/clear.go b/go/cmd/dolt/commands/stashcmds/clear.go index 7688a6e2e3..c7d1f09aec 100644 --- a/go/cmd/dolt/commands/stashcmds/clear.go +++ b/go/cmd/dolt/commands/stashcmds/clear.go @@ -63,7 +63,7 @@ func (cmd StashClearCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/drop.go b/go/cmd/dolt/commands/stashcmds/drop.go index 52f83e67b3..bc45613dd3 100644 --- a/go/cmd/dolt/commands/stashcmds/drop.go +++ b/go/cmd/dolt/commands/stashcmds/drop.go @@ -66,7 +66,7 @@ func (cmd StashDropCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/list.go b/go/cmd/dolt/commands/stashcmds/list.go index 35b44b5c51..03a5983bfc 100644 --- a/go/cmd/dolt/commands/stashcmds/list.go +++ b/go/cmd/dolt/commands/stashcmds/list.go @@ -63,7 +63,7 @@ func (cmd StashListCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/pop.go b/go/cmd/dolt/commands/stashcmds/pop.go index 6208bdc6fc..d52426d05c 100644 --- a/go/cmd/dolt/commands/stashcmds/pop.go +++ b/go/cmd/dolt/commands/stashcmds/pop.go @@ -70,7 +70,7 @@ func (cmd StashPopCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 @@ -104,7 +104,7 @@ func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []strin return handleStashPopErr(usage, err) } - ret := commands.StatusCmd{}.Exec(ctx, "status", []string{}, dEnv) + ret := commands.StatusCmd{}.Exec(ctx, "status", []string{}, dEnv, nil) if ret != 0 || !success { cli.Println("The stash entry is kept in case you need it again.") return 1 diff --git a/go/cmd/dolt/commands/stashcmds/stash.go b/go/cmd/dolt/commands/stashcmds/stash.go index 79ffba3ec7..c4cfc446b2 100644 --- a/go/cmd/dolt/commands/stashcmds/stash.go +++ b/go/cmd/dolt/commands/stashcmds/stash.go @@ -88,7 +88,7 @@ func (cmd StashCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/status.go b/go/cmd/dolt/commands/status.go index 2c07d00922..1d40f1beac 100644 --- a/go/cmd/dolt/commands/status.go +++ b/go/cmd/dolt/commands/status.go @@ -61,7 +61,7 @@ func (cmd StatusCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, statusDocs, ap)) cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tag.go b/go/cmd/dolt/commands/tag.go index 6ec23a154a..51260dc91a 100644 --- a/go/cmd/dolt/commands/tag.go +++ b/go/cmd/dolt/commands/tag.go @@ -71,7 +71,7 @@ func (cmd TagCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cli.CreateTagArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tagDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tblcmds/cp.go b/go/cmd/dolt/commands/tblcmds/cp.go index 09084c8408..076fce0eab 100644 --- a/go/cmd/dolt/commands/tblcmds/cp.go +++ b/go/cmd/dolt/commands/tblcmds/cp.go @@ -70,7 +70,7 @@ func (cmd CpCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblCpDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -94,5 +94,5 @@ func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEn fmt.Sprintf("--%s", commands.BatchFlag), fmt.Sprintf(`--%s`, commands.QueryFlag), queryStr, - }, dEnv) + }, dEnv, nil) } diff --git a/go/cmd/dolt/commands/tblcmds/export.go b/go/cmd/dolt/commands/tblcmds/export.go index dbaa425de0..89c190d28c 100644 --- a/go/cmd/dolt/commands/tblcmds/export.go +++ b/go/cmd/dolt/commands/tblcmds/export.go @@ -185,7 +185,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() _, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, exportDocs, ap)) diff --git a/go/cmd/dolt/commands/tblcmds/import.go b/go/cmd/dolt/commands/tblcmds/import.go index 4d80be4b77..df0b21e851 100644 --- a/go/cmd/dolt/commands/tblcmds/import.go +++ b/go/cmd/dolt/commands/tblcmds/import.go @@ -372,7 +372,7 @@ func (cmd ImportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap)) diff --git a/go/cmd/dolt/commands/tblcmds/mv.go b/go/cmd/dolt/commands/tblcmds/mv.go index c3a1480ff9..6df76c83ce 100644 --- a/go/cmd/dolt/commands/tblcmds/mv.go +++ b/go/cmd/dolt/commands/tblcmds/mv.go @@ -72,7 +72,7 @@ func (cmd MvCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblMvDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -95,5 +95,5 @@ func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEn fmt.Sprintf("--%s", commands.BatchFlag), fmt.Sprintf(`--%s`, commands.QueryFlag), queryStr, - }, dEnv) + }, dEnv, nil) } diff --git a/go/cmd/dolt/commands/tblcmds/rm.go b/go/cmd/dolt/commands/tblcmds/rm.go index 6b131c0977..02b75bc28f 100644 --- a/go/cmd/dolt/commands/tblcmds/rm.go +++ b/go/cmd/dolt/commands/tblcmds/rm.go @@ -66,7 +66,7 @@ func (cmd RmCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblRmDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) @@ -93,5 +93,5 @@ func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEn fmt.Sprintf("--%s", commands.BatchFlag), fmt.Sprintf(`--%s`, commands.QueryFlag), queryStr, - }, dEnv) + }, dEnv, nil) } diff --git a/go/cmd/dolt/commands/version.go b/go/cmd/dolt/commands/version.go index 4f54da2e10..95504598b8 100644 --- a/go/cmd/dolt/commands/version.go +++ b/go/cmd/dolt/commands/version.go @@ -60,7 +60,7 @@ func (cmd VersionCmd) ArgParser() *argparser.ArgParser { // Version displays the version of the running dolt client // Exec executes the command -func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int { +func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { cli.Println("dolt version", cmd.VersionStr) if dEnv.HasDoltDir() && dEnv.RSLoadErr == nil && !cli.CheckEnvIsValid(dEnv) { diff --git a/go/cmd/dolt/dolt.go b/go/cmd/dolt/dolt.go index dcebaa57ee..b2afffe730 100644 --- a/go/cmd/dolt/dolt.go +++ b/go/cmd/dolt/dolt.go @@ -403,7 +403,7 @@ func runMain() int { start := time.Now() ctx, stop := context.WithCancel(ctx) - res := doltCommand.Exec(ctx, "dolt", args, dEnv) + res := doltCommand.Exec(ctx, "dolt", args, dEnv, nil) stop() if err = dbfactory.CloseAllLocalDatabases(); err != nil { @@ -464,5 +464,5 @@ func interceptSendMetrics(ctx context.Context, args []string) (bool, int) { return false, 0 } dEnv := env.LoadWithoutDB(ctx, env.GetCurrentUserHomeDir, filesys.LocalFS, Version) - return true, doltCommand.Exec(ctx, "dolt", args, dEnv) + return true, doltCommand.Exec(ctx, "dolt", args, dEnv, nil) } diff --git a/go/libraries/doltcore/doltdb/feature_version_test.go b/go/libraries/doltcore/doltdb/feature_version_test.go index 2f842b71d4..b6a07552ab 100644 --- a/go/libraries/doltcore/doltdb/feature_version_test.go +++ b/go/libraries/doltcore/doltdb/feature_version_test.go @@ -58,7 +58,7 @@ func (cmd fvCommand) exec(ctx context.Context, dEnv *env.DoltEnv) int { // execute the command using |cmd.user|'s Feature Version doltdb.DoltFeatureVersion = cmd.user.vers defer func() { doltdb.DoltFeatureVersion = DoltFeatureVersionCopy }() - return cmd.cmd.Exec(ctx, cmd.cmd.Name(), cmd.args, dEnv) + return cmd.cmd.Exec(ctx, cmd.cmd.Name(), cmd.args, dEnv, nil) } type fvUser struct { diff --git a/go/libraries/doltcore/doltdb/foreign_key_test.go b/go/libraries/doltcore/doltdb/foreign_key_test.go index e21a62587e..f41372bd88 100644 --- a/go/libraries/doltcore/doltdb/foreign_key_test.go +++ b/go/libraries/doltcore/doltdb/foreign_key_test.go @@ -49,13 +49,13 @@ func TestForeignKeyErrors(t *testing.T) { dEnv := dtestutils.CreateTestEnv() for _, c := range cmds { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } - exitCode := commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test MODIFY v1 INT;`}, dEnv) + exitCode := commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test MODIFY v1 INT;`}, dEnv, nil) require.Equal(t, 1, exitCode) - exitCode = commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test2 MODIFY v1 INT;`}, dEnv) + exitCode = commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test2 MODIFY v1 INT;`}, dEnv, nil) require.Equal(t, 1, exitCode) } @@ -96,11 +96,11 @@ func testForeignKeys(t *testing.T, test foreignKeyTest) { dEnv := dtestutils.CreateTestEnv() for _, c := range fkSetupCommon { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } for _, c := range test.setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } diff --git a/go/libraries/doltcore/doltdb/gc_test.go b/go/libraries/doltcore/doltdb/gc_test.go index 3b1b2a465d..3d8b8d479f 100644 --- a/go/libraries/doltcore/doltdb/gc_test.go +++ b/go/libraries/doltcore/doltdb/gc_test.go @@ -113,7 +113,7 @@ func testGarbageCollection(t *testing.T, test gcTest) { defer dEnv.DoltDB.Close() for _, c := range gcSetupCommon { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } @@ -121,7 +121,7 @@ func testGarbageCollection(t *testing.T, test gcTest) { for _, stage := range test.stages { res = stage.preStageFunc(ctx, t, dEnv.DoltDB, res) for _, c := range stage.commands { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } } diff --git a/go/libraries/doltcore/merge/keyless_integration_test.go b/go/libraries/doltcore/merge/keyless_integration_test.go index b27e67f86c..5c6df45832 100644 --- a/go/libraries/doltcore/merge/keyless_integration_test.go +++ b/go/libraries/doltcore/merge/keyless_integration_test.go @@ -116,7 +116,7 @@ func TestKeylessMerge(t *testing.T) { require.NoError(t, err) for _, c := range test.setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } @@ -249,7 +249,7 @@ func TestKeylessMergeConflicts(t *testing.T) { require.NoError(t, err) for _, c := range cc { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } } @@ -278,7 +278,7 @@ func TestKeylessMergeConflicts(t *testing.T) { resolve := cnfcmds.ResolveCmd{} args := []string{"--ours", tblName} - exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv) + exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv, nil) require.Equal(t, 0, exitCode) root, err := dEnv.WorkingRoot(ctx) @@ -296,7 +296,7 @@ func TestKeylessMergeConflicts(t *testing.T) { resolve := cnfcmds.ResolveCmd{} args := []string{"--theirs", tblName} - exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv) + exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv, nil) require.Equal(t, 0, exitCode) root, err := dEnv.WorkingRoot(ctx) diff --git a/go/libraries/doltcore/merge/schema_integration_test.go b/go/libraries/doltcore/merge/schema_integration_test.go index 4cbcc22ec8..531c0ca2b2 100644 --- a/go/libraries/doltcore/merge/schema_integration_test.go +++ b/go/libraries/doltcore/merge/schema_integration_test.go @@ -40,7 +40,7 @@ type testCommand struct { } func (tc testCommand) exec(t *testing.T, ctx context.Context, dEnv *env.DoltEnv) { - exitCode := tc.cmd.Exec(ctx, tc.cmd.Name(), tc.args, dEnv) + exitCode := tc.cmd.Exec(ctx, tc.cmd.Name(), tc.args, dEnv, nil) require.Equal(t, 0, exitCode) } @@ -569,11 +569,11 @@ func testMergeSchemas(t *testing.T, test mergeSchemaTest) { } // assert that we're on main - exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv) + exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil) require.Equal(t, 0, exitCode) // merge branches - exitCode = commands.MergeCmd{}.Exec(ctx, "merge", []string{"other"}, dEnv) + exitCode = commands.MergeCmd{}.Exec(ctx, "merge", []string{"other"}, dEnv, nil) assert.Equal(t, 0, exitCode) wr, err := dEnv.WorkingRoot(ctx) @@ -615,12 +615,12 @@ func testMergeSchemasWithConflicts(t *testing.T, test mergeSchemaConflictTest) { } // assert that we're on main - exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv) + exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil) require.Equal(t, 0, exitCode) mainSch := getSchema(t, dEnv) - exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv) + exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv, nil) require.Equal(t, 0, exitCode) otherSch := getSchema(t, dEnv) @@ -671,14 +671,14 @@ func testMergeForeignKeys(t *testing.T, test mergeForeignKeyTest) { } // assert that we're on main - exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv) + exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil) require.Equal(t, 0, exitCode) mainWS, err := dEnv.WorkingSet(ctx) require.NoError(t, err) mainRoot := mainWS.WorkingRoot() - exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv) + exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv, nil) require.Equal(t, 0, exitCode) otherWS, err := dEnv.WorkingSet(ctx) diff --git a/go/libraries/doltcore/migrate/integration_test.go b/go/libraries/doltcore/migrate/integration_test.go index b2f3c5f9e0..8fbe86065a 100644 --- a/go/libraries/doltcore/migrate/integration_test.go +++ b/go/libraries/doltcore/migrate/integration_test.go @@ -173,7 +173,7 @@ func setupMigrationTest(t *testing.T, ctx context.Context, test migrationTest) * cmd := commands.SqlCmd{} for _, query := range test.setup { - code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv) + code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv, nil) require.Equal(t, 0, code) } return dEnv diff --git a/go/libraries/doltcore/rebase/filter_branch_test.go b/go/libraries/doltcore/rebase/filter_branch_test.go index 9b1ca40070..f2e3868f16 100644 --- a/go/libraries/doltcore/rebase/filter_branch_test.go +++ b/go/libraries/doltcore/rebase/filter_branch_test.go @@ -203,7 +203,7 @@ func setupFilterBranchTests(t *testing.T) *env.DoltEnv { ctx := context.Background() dEnv := dtestutils.CreateTestEnv() for _, c := range setupCommon { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } @@ -215,13 +215,13 @@ func testFilterBranch(t *testing.T, test filterBranchTest) { dEnv := setupFilterBranchTests(t) defer dEnv.DoltDB.Close() for _, c := range test.setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } for _, a := range test.asserts { for _, c := range a.setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } diff --git a/go/libraries/doltcore/schema/integration_test.go b/go/libraries/doltcore/schema/integration_test.go index aabb2244f5..7d4a8b7367 100644 --- a/go/libraries/doltcore/schema/integration_test.go +++ b/go/libraries/doltcore/schema/integration_test.go @@ -177,7 +177,7 @@ func runTestSql(t *testing.T, ctx context.Context, setup []string) (*doltdb.Dolt dEnv := dtestutils.CreateTestEnv() cmd := commands.SqlCmd{} for _, query := range setup { - code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv) + code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv, nil) require.Equal(t, 0, code) } root, err := dEnv.WorkingRoot(ctx) diff --git a/go/libraries/doltcore/sqle/integration_test/database_revision_test.go b/go/libraries/doltcore/sqle/integration_test/database_revision_test.go index 71dfd2b892..45f0b146a8 100644 --- a/go/libraries/doltcore/sqle/integration_test/database_revision_test.go +++ b/go/libraries/doltcore/sqle/integration_test/database_revision_test.go @@ -154,7 +154,7 @@ func TestDbRevision(t *testing.T) { setup := append(setupCommon, test.setup...) for _, c := range setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } diff --git a/go/libraries/doltcore/sqle/integration_test/history_table_test.go b/go/libraries/doltcore/sqle/integration_test/history_table_test.go index 81942b1ed2..8624623a50 100644 --- a/go/libraries/doltcore/sqle/integration_test/history_table_test.go +++ b/go/libraries/doltcore/sqle/integration_test/history_table_test.go @@ -213,7 +213,7 @@ func setupHistoryTests(t *testing.T) *env.DoltEnv { ctx := context.Background() dEnv := dtestutils.CreateTestEnv() for _, c := range setupCommon { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } @@ -237,7 +237,7 @@ func setupHistoryTests(t *testing.T) *env.DoltEnv { func testHistoryTable(t *testing.T, test historyTableTest, dEnv *env.DoltEnv) { ctx := context.Background() for _, c := range test.setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } diff --git a/go/libraries/doltcore/sqle/integration_test/json_value_test.go b/go/libraries/doltcore/sqle/integration_test/json_value_test.go index 94f038511a..4d66e19839 100644 --- a/go/libraries/doltcore/sqle/integration_test/json_value_test.go +++ b/go/libraries/doltcore/sqle/integration_test/json_value_test.go @@ -129,7 +129,7 @@ func testJsonValue(t *testing.T, test jsonValueTest, setupCommon []testCommand) setup := append(setupCommon, test.setup...) for _, c := range setup { - exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv) + exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil) require.Equal(t, 0, exitCode) } diff --git a/go/performance/microsysbench/sysbench_test.go b/go/performance/microsysbench/sysbench_test.go index 61bdedd5bd..e3ae78c1aa 100644 --- a/go/performance/microsysbench/sysbench_test.go +++ b/go/performance/microsysbench/sysbench_test.go @@ -140,7 +140,7 @@ func populateRepo(dEnv *env.DoltEnv, insertData string) { execSql := func(dEnv *env.DoltEnv, q string) int { ctx := context.Background() args := []string{"-r", "null", "-q", q} - return commands.SqlCmd{}.Exec(ctx, "sql", args, dEnv) + return commands.SqlCmd{}.Exec(ctx, "sql", args, dEnv, nil) } execSql(dEnv, createTable) execSql(dEnv, insertData) From 6086c4f0490d75dda202116c7f6ac8ba18edb981 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Tue, 18 Apr 2023 15:47:08 -0700 Subject: [PATCH 11/22] Add Server Runtime details to the sql-server.lock file --- go/cmd/dolt/commands/sqlserver/server.go | 11 ++- go/libraries/doltcore/env/environment.go | 88 +++++++++++++++---- go/libraries/doltcore/env/multi_repo_env.go | 7 +- .../binlog_metadata_persistence.go | 6 +- .../binlog_replica_applier.go | 4 +- .../binlog_replica_controller.go | 2 +- .../doltcore/sqle/database_provider.go | 7 +- .../doltcore/sqle/dprocedures/dolt_branch.go | 2 +- .../doltcore/sqlserver/dolt_server.go | 50 ++++++++--- 9 files changed, 128 insertions(+), 49 deletions(-) diff --git a/go/cmd/dolt/commands/sqlserver/server.go b/go/cmd/dolt/commands/sqlserver/server.go index 1e7d54fe23..fc22452648 100644 --- a/go/cmd/dolt/commands/sqlserver/server.go +++ b/go/cmd/dolt/commands/sqlserver/server.go @@ -66,7 +66,7 @@ func Serve( } serverController.StopServer() serverController.serverStopped(closeError) - sqlserver.SetRunningServer(nil) + sqlserver.UnsetRunningServer() }() if startError = ValidateConfig(serverConfig); startError != nil { @@ -211,7 +211,9 @@ func Serve( cli.PrintErr(startError) return } - sqlserver.SetRunningServer(mySQLServer) + + lck := env.NewDBLock(serverConfig.Port()) + sqlserver.SetRunningServer(mySQLServer, &lck) var metSrv *http.Server if serverConfig.MetricsHost() != "" && serverConfig.MetricsPort() > 0 { @@ -311,7 +313,8 @@ func Serve( startError = env.ErrActiveServerLock.New(f) return } - if err = mrEnv.Lock(); err != nil { + + if err = mrEnv.Lock(lck); err != nil { startError = err return } @@ -390,7 +393,7 @@ func newSessionBuilder(se *engine.SqlEngine, config ServerConfig) server.Session dsess, err := se.NewDoltSession(ctx, mysqlBaseSess) if err != nil { if goerrors.Is(err, env.ErrFailedToAccessDB) { - if server := sqlserver.GetRunningServer(); server != nil { + if server, _ := sqlserver.GetRunningServer(); server != nil { _ = server.Close() } } diff --git a/go/libraries/doltcore/env/environment.go b/go/libraries/doltcore/env/environment.go index 9135235935..22f30f008a 100644 --- a/go/libraries/doltcore/env/environment.go +++ b/go/libraries/doltcore/env/environment.go @@ -18,6 +18,7 @@ import ( "context" "errors" "fmt" + "github.com/google/uuid" "os" "path/filepath" "strconv" @@ -1195,8 +1196,21 @@ func (dEnv *DoltEnv) IsLocked() bool { return FsIsLocked(dEnv.FS) } +// DBLock is a struct that contains the pid of the process that created the lockfile and the port that the server is running on +// The secret is used by dolt to ensure that the contents of the lockfile are required to perform a local server connection +type DBLock struct { + Pid int + Port int + Secret string +} + +// DBLock constructor +func NewDBLock(port int) DBLock { + return DBLock{Pid: os.Getpid(), Port: port, Secret: uuid.New().String()} +} + // Lock writes this database's lockfile with the pid of the calling process or errors if it already exists -func (dEnv *DoltEnv) Lock() error { +func (dEnv *DoltEnv) Lock(lock DBLock) error { if dEnv.IgnoreLockFile { return nil } @@ -1205,31 +1219,49 @@ func (dEnv *DoltEnv) Lock() error { return ErrActiveServerLock.New(dEnv.LockFile()) } - return WriteLockfile(dEnv.FS) + return WriteLockfile(dEnv.FS, lock) } -func getProcessFromLockFile(fs filesys.Filesys, lockFile string) (int, error) { - // validate that the pid on the lock file is still active - rd, err := fs.OpenForRead(lockFile) +func LoadDBLockFile(fs filesys.Filesys, lockFilePath string) (lock *DBLock, err error) { + rd, err := fs.OpenForRead(lockFilePath) if err != nil { - return -1, err + return nil, err } - // Technically, the max pid is bounded by int types (~32 bits). That gets - // encoded to about 11 bytes. We'll round about just in case. - b := make([]byte, 50) + b := make([]byte, 256) n, err := rd.Read(b) if err != nil { - return -1, err + return nil, err } data := strings.TrimSpace(string(b[:n])) - pid, err := strconv.Atoi(data) - if err != nil { - return -1, err + + parts := strings.Split(data, ":") + if len(parts) == 1 { + // Legacy Lock file. We can remove this code path in a couple of months (6/2023) + pid, err := strconv.Atoi(parts[0]) + if err != nil { + return nil, err + } + return &DBLock{Pid: pid, Port: -1, Secret: ""}, nil + } + if len(parts) != 3 { + return nil, fmt.Errorf("invalid lock file format") } - return pid, nil + pid, err := strconv.Atoi(parts[0]) + if err != nil { + return nil, err + } + port := -1 + if parts[1] != "-" { + port, err = strconv.Atoi(parts[1]) + if err != nil { + return nil, err + } + } + secret := parts[2] + return &DBLock{Pid: pid, Port: port, Secret: secret}, nil } // Unlock deletes this database's lockfile @@ -1242,9 +1274,29 @@ func (dEnv *DoltEnv) Unlock() error { } // WriteLockfile writes a lockfile encoding the pid of the calling process. -func WriteLockfile(fs filesys.Filesys) error { +func WriteLockfile(fs filesys.Filesys, lock DBLock) error { lockFile, _ := fs.Abs(filepath.Join(dbfactory.DoltDir, ServerLockFile)) - return fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d", os.Getpid()))) + + portStr := strconv.Itoa(lock.Port) + if lock.Port < 0 { + portStr = "-" + } + + _, err := os.Create(lockFile) + if err != nil { + return err + } + err = os.Chmod(lockFile, 0600) + if err != nil { + return err + } + + err = fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d:%s:%s", lock.Pid, portStr, lock.Secret))) + if err != nil { + return err + } + + return nil } // FsIsLocked returns true if a lockFile exists with the same pid as @@ -1257,13 +1309,13 @@ func FsIsLocked(fs filesys.Filesys) bool { return false } - lockFilePid, err := getProcessFromLockFile(fs, lockFile) + loadedLock, err := LoadDBLockFile(fs, lockFile) if err != nil { // if there's any error assume that env is locked since the file exists return true } // Check whether the pid that spawned the lock file is still running. Ignore it if not. - p, err := ps.FindProcess(lockFilePid) + p, err := ps.FindProcess(loadedLock.Pid) if err != nil { return false } diff --git a/go/libraries/doltcore/env/multi_repo_env.go b/go/libraries/doltcore/env/multi_repo_env.go index 7cb82e6977..b210b1af53 100644 --- a/go/libraries/doltcore/env/multi_repo_env.go +++ b/go/libraries/doltcore/env/multi_repo_env.go @@ -282,9 +282,9 @@ func (mrEnv *MultiRepoEnv) IsLocked() (bool, string) { return false, "" } -// Lock locks all child envs. If an error is returned, all +// Lock locks all child envs. The DBLock contains the details to write to the lock files. If an error is returned, all // child envs will be returned with their initial lock state. -func (mrEnv *MultiRepoEnv) Lock() error { +func (mrEnv *MultiRepoEnv) Lock(lck DBLock) (err error) { if mrEnv.ignoreLockFile { return nil } @@ -293,9 +293,8 @@ func (mrEnv *MultiRepoEnv) Lock() error { return ErrActiveServerLock.New(f) } - var err error for _, e := range mrEnv.envs { - err = e.env.Lock() + err = e.env.Lock(lck) if err != nil { mrEnv.Unlock() return err diff --git a/go/libraries/doltcore/sqle/binlogreplication/binlog_metadata_persistence.go b/go/libraries/doltcore/sqle/binlogreplication/binlog_metadata_persistence.go index 7709146bc9..3b4c8c7d2c 100644 --- a/go/libraries/doltcore/sqle/binlogreplication/binlog_metadata_persistence.go +++ b/go/libraries/doltcore/sqle/binlogreplication/binlog_metadata_persistence.go @@ -26,7 +26,7 @@ import ( // persistReplicationConfiguration saves the specified |replicaSourceInfo| to disk; if any problems are encountered // while saving to disk, an error is returned. func persistReplicationConfiguration(ctx *sql.Context, replicaSourceInfo *mysql_db.ReplicaSourceInfo) error { - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return fmt.Errorf("no SQL server running; " + "replication commands may only be used when running from dolt sql-server, and not from dolt sql") @@ -43,7 +43,7 @@ func persistReplicationConfiguration(ctx *sql.Context, replicaSourceInfo *mysql_ // loadReplicationConfiguration loads the replication configuration for default channel (""). func loadReplicationConfiguration(_ *sql.Context) (*mysql_db.ReplicaSourceInfo, error) { - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return nil, fmt.Errorf("no SQL server running; " + "replication commands may only be used when running from dolt sql-server, and not from dolt sql") @@ -66,7 +66,7 @@ func loadReplicationConfiguration(_ *sql.Context) (*mysql_db.ReplicaSourceInfo, // deleteReplicationConfiguration deletes all replication configuration for the default channel (""). func deleteReplicationConfiguration(ctx *sql.Context) error { - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return fmt.Errorf("no SQL server running; " + "replication commands may only be used when running from dolt sql-server, and not from dolt sql") diff --git a/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_applier.go b/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_applier.go index aa1b1d80e0..07ae7f089e 100644 --- a/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_applier.go +++ b/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_applier.go @@ -252,7 +252,7 @@ func (a *binlogReplicaApplier) startReplicationEventStream(ctx *sql.Context, con // replicaBinlogEventHandler runs a loop, processing binlog events until the applier's stop replication channel // receives a signal to stop. func (a *binlogReplicaApplier) replicaBinlogEventHandler(ctx *sql.Context) error { - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return fmt.Errorf("unable to access a running SQL server") } @@ -877,7 +877,7 @@ func convertVitessJsonExpressionString(ctx *sql.Context, value sqltypes.Value) ( return nil, err } - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return nil, fmt.Errorf("unable to access running SQL server") } diff --git a/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_controller.go b/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_controller.go index e1ac35b3c0..8091650a69 100644 --- a/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_controller.go +++ b/go/libraries/doltcore/sqle/binlogreplication/binlog_replica_controller.go @@ -151,7 +151,7 @@ func (d *doltBinlogReplicaController) StartReplica(ctx *sql.Context) error { // created and locked to disable log ins, and if it does exist, but is missing super privs or is not // locked, it will be given super user privs and locked. func (d *doltBinlogReplicaController) configureReplicationUser(ctx *sql.Context) error { - server := sqlserver.GetRunningServer() + server, _ := sqlserver.GetRunningServer() if server == nil { return fmt.Errorf("unable to access a running SQL server") } diff --git a/go/libraries/doltcore/sqle/database_provider.go b/go/libraries/doltcore/sqle/database_provider.go index be254f82f6..b704f9f47b 100644 --- a/go/libraries/doltcore/sqle/database_provider.go +++ b/go/libraries/doltcore/sqle/database_provider.go @@ -410,8 +410,9 @@ func (p DoltDatabaseProvider) CreateCollatedDatabase(ctx *sql.Context, name stri // If we're running in a sql-server context, ensure the new database is locked so that it can't // be edited from the CLI. We can't rely on looking for an existing lock file, since this could // be the first db creation if sql-server was started from a bare directory. - if sqlserver.GetRunningServer() != nil { - err = newEnv.Lock() + _, lckDeets := sqlserver.GetRunningServer() + if lckDeets != nil { + err = newEnv.Lock(*lckDeets) if err != nil { ctx.GetLogger().Warnf("Failed to lock newly created database: %s", err.Error()) } @@ -687,7 +688,7 @@ func (p DoltDatabaseProvider) invalidateDbStateInAllSessions(ctx *sql.Context, n } // If we have a running server, remove it from other sessions as well - runningServer := sqlserver.GetRunningServer() + runningServer, _ := sqlserver.GetRunningServer() if runningServer != nil { sessionManager := runningServer.SessionManager() err := sessionManager.Iter(func(session sql.Session) (bool, error) { diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_branch.go b/go/libraries/doltcore/sqle/dprocedures/dolt_branch.go index b7526ce4f2..2d707d75d7 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_branch.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_branch.go @@ -215,7 +215,7 @@ func validateBranchNotActiveInAnySession(ctx *sql.Context, branchName string) er return nil } - runningServer := sqlserver.GetRunningServer() + runningServer, _ := sqlserver.GetRunningServer() if runningServer == nil { return nil } diff --git a/go/libraries/doltcore/sqlserver/dolt_server.go b/go/libraries/doltcore/sqlserver/dolt_server.go index b34273da2d..4bc704db79 100644 --- a/go/libraries/doltcore/sqlserver/dolt_server.go +++ b/go/libraries/doltcore/sqlserver/dolt_server.go @@ -15,31 +15,55 @@ package sqlserver import ( + "fmt" + "github.com/dolthub/dolt/go/libraries/doltcore/env" "sync" "github.com/dolthub/go-mysql-server/server" ) -var mySQLServer *server.Server -var mySQLServerMutex sync.Mutex +var lockedDetails *serverAndLockfile +var mutex sync.Mutex + +// Struct for holding a *server.Server and a *env.DBLock +type serverAndLockfile struct { + Server *server.Server + Lockfile *env.DBLock +} // RunningInServerMode returns true if the current process is running a SQL server. func RunningInServerMode() bool { - mySQLServerMutex.Lock() - defer mySQLServerMutex.Unlock() - return mySQLServer != nil + mutex.Lock() + defer mutex.Unlock() + return lockedDetails != nil } // GetRunningServer returns the Server instance running in this process, or nil if no SQL server is running. -func GetRunningServer() *server.Server { - mySQLServerMutex.Lock() - defer mySQLServerMutex.Unlock() - return mySQLServer +func GetRunningServer() (*server.Server, *env.DBLock) { + mutex.Lock() + defer mutex.Unlock() + + if lockedDetails == nil { + return nil, nil + } + return lockedDetails.Server, lockedDetails.Lockfile } // SetRunningServer sets the specified Server as the running SQL server for this process. -func SetRunningServer(server *server.Server) { - mySQLServerMutex.Lock() - defer mySQLServerMutex.Unlock() - mySQLServer = server +func SetRunningServer(server *server.Server, lockfile *env.DBLock) error { + if server == nil || lockfile == nil { + return fmt.Errorf("server and lockfile must be non-nil") + } + + mutex.Lock() + defer mutex.Unlock() + lockedDetails = &serverAndLockfile{Server: server, Lockfile: lockfile} + + return nil +} + +func UnsetRunningServer() { + mutex.Lock() + defer mutex.Unlock() + lockedDetails = nil } From 9ff561d96c169e3185f6216f1be8dae0d4dc7995 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Wed, 19 Apr 2023 10:01:24 -0700 Subject: [PATCH 12/22] Only apply file access restrictions when using the LocalFS --- go/libraries/doltcore/env/environment.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/go/libraries/doltcore/env/environment.go b/go/libraries/doltcore/env/environment.go index 22f30f008a..cbfd47eaea 100644 --- a/go/libraries/doltcore/env/environment.go +++ b/go/libraries/doltcore/env/environment.go @@ -1282,16 +1282,18 @@ func WriteLockfile(fs filesys.Filesys, lock DBLock) error { portStr = "-" } - _, err := os.Create(lockFile) - if err != nil { - return err - } - err = os.Chmod(lockFile, 0600) - if err != nil { - return err + if filesys.LocalFS == fs { + _, err := os.Create(lockFile) + if err != nil { + return err + } + err = os.Chmod(lockFile, 0600) + if err != nil { + return err + } } - err = fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d:%s:%s", lock.Pid, portStr, lock.Secret))) + err := fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d:%s:%s", lock.Pid, portStr, lock.Secret))) if err != nil { return err } From 32ef60f38e8a6b73354a5f591b9324213d35aba8 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Wed, 19 Apr 2023 14:22:16 -0700 Subject: [PATCH 13/22] Check the permissions in bats test --- integration-tests/bats/sql-server.bats | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/integration-tests/bats/sql-server.bats b/integration-tests/bats/sql-server.bats index a23e5b83df..6bce8a1722 100644 --- a/integration-tests/bats/sql-server.bats +++ b/integration-tests/bats/sql-server.bats @@ -243,7 +243,7 @@ SQL # check that dolt_commit throws an error when there are no changes to commit run dolt sql-client -P $PORT -u dolt --no-auto-commit -q "CALL DOLT_COMMIT('-a', '-m', 'Commit1')" [ $status -ne 0 ] - [[ "$output" =~ "nothing to commit" ]] || false + [[ "$output" =~ "nothing to commit" ]] || false run dolt ls [ "$status" -eq 0 ] @@ -1076,6 +1076,7 @@ END""") # Make sure the sql-server lock file is set for a newly created database [[ -f "$PWD/test1/.dolt/sql-server.lock" ]] || false + [[ $(stat -f "%Lp" "$PWD/test1/.dolt/sql-server.lock") == "600" ]] || false dolt sql-client -P $PORT -u dolt --use-db 'test1' -q "create table a(x int)" dolt sql-client -P $PORT -u dolt --use-db 'test1' -q "call dolt_add('.')" @@ -1446,6 +1447,14 @@ databases: [ "$status" -eq 1 ] } +@test "sql-server: sql-server sets permissions on sql-server.lock" { + cd repo1 + ! [[ -f "$PWD/.dolt/sql-server.lock" ]] || false + start_sql_server + [[ -f "$PWD/.dolt/sql-server.lock" ]] || false + [[ $(stat -f "%Lp" "$PWD/.dolt/sql-server.lock") == "600" ]] || false +} + @test "sql-server: multi dir sql-server locks out children" { start_sql_server cd repo2 @@ -1470,6 +1479,7 @@ databases: # Make sure the sql-server lock file is set for the new database [[ -f "$PWD/newdb/.dolt/sql-server.lock" ]] || false + [[ $(stat -f "%Lp" "$PWD/newdb/.dolt/sql-server.lock") == "600" ]] || false # Verify that we can't start a sql-server from the new database dir cd newdb From f08b325a3eb438dc4994c37bbc64c93218d818a0 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Wed, 19 Apr 2023 17:40:07 -0700 Subject: [PATCH 14/22] stat command differs between MacOS and Ubuntu --- integration-tests/bats/sql-server.bats | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/integration-tests/bats/sql-server.bats b/integration-tests/bats/sql-server.bats index 6bce8a1722..e0ff658212 100644 --- a/integration-tests/bats/sql-server.bats +++ b/integration-tests/bats/sql-server.bats @@ -1076,7 +1076,6 @@ END""") # Make sure the sql-server lock file is set for a newly created database [[ -f "$PWD/test1/.dolt/sql-server.lock" ]] || false - [[ $(stat -f "%Lp" "$PWD/test1/.dolt/sql-server.lock") == "600" ]] || false dolt sql-client -P $PORT -u dolt --use-db 'test1' -q "create table a(x int)" dolt sql-client -P $PORT -u dolt --use-db 'test1' -q "call dolt_add('.')" @@ -1452,7 +1451,15 @@ databases: ! [[ -f "$PWD/.dolt/sql-server.lock" ]] || false start_sql_server [[ -f "$PWD/.dolt/sql-server.lock" ]] || false - [[ $(stat -f "%Lp" "$PWD/.dolt/sql-server.lock") == "600" ]] || false + + + if [[ `uname` == 'Darwin' ]]; then + run stat -x "$PWD/.dolt/sql-server.lock" + [[ "$output" =~ "(0600/-rw-------)" ]] || false + else + run stat "$PWD/.dolt/sql-server.lock" + [[ "$output" =~ "(0600/-rw-------)" ]] || false + fi } @test "sql-server: multi dir sql-server locks out children" { @@ -1479,7 +1486,6 @@ databases: # Make sure the sql-server lock file is set for the new database [[ -f "$PWD/newdb/.dolt/sql-server.lock" ]] || false - [[ $(stat -f "%Lp" "$PWD/newdb/.dolt/sql-server.lock") == "600" ]] || false # Verify that we can't start a sql-server from the new database dir cd newdb From 43e3fc57a2e10e93a1630c6fe693ed8cc0286fa2 Mon Sep 17 00:00:00 2001 From: coffeegoddd Date: Thu, 20 Apr 2023 16:26:17 -0700 Subject: [PATCH 15/22] /.github/workflows/ci-check-repo.yaml: only run verify on fork prs, error if not formatted with actionable error --- .github/workflows/ci-check-repo.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-check-repo.yaml b/.github/workflows/ci-check-repo.yaml index 7f4e7b266e..d33b966a73 100644 --- a/.github/workflows/ci-check-repo.yaml +++ b/.github/workflows/ci-check-repo.yaml @@ -40,6 +40,11 @@ jobs: echo "code is formatted" else echo "code is not formatted" + if [ "${{ github.repository }}" != "dolthub/dolt" ]; then + echo "Pull requests from forks must be manually formatted." + echo "Please run dolt/go/utils/repofmt/format_repo.sh to format this pull request." + exit 1; + fi echo "format=true" >> $GITHUB_OUTPUT fi env: From db16848f09daa87ed5718f2c638adf9f2b3c156a Mon Sep 17 00:00:00 2001 From: Neil Macneale IV <46170177+macneale4@users.noreply.github.com> Date: Thu, 20 Apr 2023 11:14:01 -0700 Subject: [PATCH 16/22] Update go/libraries/doltcore/sqlserver/dolt_server.go Co-authored-by: Jason Fulghum --- go/libraries/doltcore/sqlserver/dolt_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/libraries/doltcore/sqlserver/dolt_server.go b/go/libraries/doltcore/sqlserver/dolt_server.go index 4bc704db79..668658f44a 100644 --- a/go/libraries/doltcore/sqlserver/dolt_server.go +++ b/go/libraries/doltcore/sqlserver/dolt_server.go @@ -25,7 +25,7 @@ import ( var lockedDetails *serverAndLockfile var mutex sync.Mutex -// Struct for holding a *server.Server and a *env.DBLock +// serverAndLockfile holds a *server.Server and a *env.DBLock for a running server type serverAndLockfile struct { Server *server.Server Lockfile *env.DBLock From caf69cdc0e5c816145d038f1e360c47189ab412e Mon Sep 17 00:00:00 2001 From: macneale4 Date: Thu, 20 Apr 2023 23:51:00 +0000 Subject: [PATCH 17/22] [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --- .../dolt/services/eventsapi/v1alpha1/client_event.pb.go | 5 +++-- .../dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go | 1 + .../dolt/services/eventsapi/v1alpha1/event_constants.pb.go | 5 +++-- .../proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go | 5 +++-- .../dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go | 1 + .../dolt/services/remotesapi/v1alpha1/credentials.pb.go | 5 +++-- .../dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go | 1 + go/libraries/doltcore/env/environment.go | 2 +- go/libraries/doltcore/sqlserver/dolt_server.go | 5 +++-- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go index 50e349ba74..6e09d77b48 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go @@ -23,12 +23,13 @@ package eventsapi import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go index 085a9fda2b..8a09ad1cf6 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go @@ -24,6 +24,7 @@ package eventsapi import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go index baf68b07c3..3052fb16a1 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go @@ -23,10 +23,11 @@ package eventsapi import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go index 0fc8ae7e15..dde8ed815b 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go @@ -21,11 +21,12 @@ package remotesapi import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go index 828da30d62..28cfc20104 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go @@ -22,6 +22,7 @@ package remotesapi import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go index 8164b2bb9a..7c2e689b33 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go @@ -21,10 +21,11 @@ package remotesapi import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go index e859388139..8ae0dfc1eb 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go @@ -22,6 +22,7 @@ package remotesapi import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/go/libraries/doltcore/env/environment.go b/go/libraries/doltcore/env/environment.go index cbfd47eaea..34ba90ad19 100644 --- a/go/libraries/doltcore/env/environment.go +++ b/go/libraries/doltcore/env/environment.go @@ -18,13 +18,13 @@ import ( "context" "errors" "fmt" - "github.com/google/uuid" "os" "path/filepath" "strconv" "strings" "time" + "github.com/google/uuid" ps "github.com/mitchellh/go-ps" goerrors "gopkg.in/src-d/go-errors.v1" diff --git a/go/libraries/doltcore/sqlserver/dolt_server.go b/go/libraries/doltcore/sqlserver/dolt_server.go index 668658f44a..adfdb28796 100644 --- a/go/libraries/doltcore/sqlserver/dolt_server.go +++ b/go/libraries/doltcore/sqlserver/dolt_server.go @@ -16,16 +16,17 @@ package sqlserver import ( "fmt" - "github.com/dolthub/dolt/go/libraries/doltcore/env" "sync" + "github.com/dolthub/dolt/go/libraries/doltcore/env" + "github.com/dolthub/go-mysql-server/server" ) var lockedDetails *serverAndLockfile var mutex sync.Mutex -// serverAndLockfile holds a *server.Server and a *env.DBLock for a running server +// serverAndLockfile holds a *server.Server and a *env.DBLock for a running server type serverAndLockfile struct { Server *server.Server Lockfile *env.DBLock From 30b9d46633dbd3a6e964b0caab4379565ce132c8 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 21 Apr 2023 10:30:32 -0700 Subject: [PATCH 18/22] Changing schema merge tests to run test cases in both directions and removing duplicated tests --- .../doltcore/merge/schema_merge_test.go | 194 ++++++------------ 1 file changed, 59 insertions(+), 135 deletions(-) diff --git a/go/libraries/doltcore/merge/schema_merge_test.go b/go/libraries/doltcore/merge/schema_merge_test.go index d03c5e2c7d..1b22edf651 100644 --- a/go/libraries/doltcore/merge/schema_merge_test.go +++ b/go/libraries/doltcore/merge/schema_merge_test.go @@ -36,13 +36,15 @@ import ( ) type schemaMergeTest struct { - name string - ancestor table - left, right table - merged table - conflict bool - skipNewFmt bool - skipOldFmt bool + name string + ancestor table + left, right table + merged table + conflict bool + skipNewFmt bool + skipOldFmt bool + skipFlipOnNewFormat bool + skipFlipOnOldFormat bool } type table struct { @@ -104,20 +106,6 @@ var columnAddDropTests = []schemaMergeTest{ right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), }, - { - name: "right side column add", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - }, - { - name: "right side column drop", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - }, // both sides change columns { name: "independent column adds", @@ -178,28 +166,13 @@ var columnAddDropTests = []schemaMergeTest{ merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, nil)), }, { - name: "left side column drop, right side insert row", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)), - skipNewFmt: true, - }, - { - name: "right side column add, left side insert row", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, nil)), - }, - { - name: "right side column drop, left side insert row", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)), - skipNewFmt: true, - skipOldFmt: true, + name: "left side column drop, right side insert row", + ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)), + left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), + right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)), + merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)), + skipNewFmt: true, + skipFlipOnOldFormat: true, }, // both sides change columns and insert rows { @@ -269,20 +242,6 @@ var columnDefaultTests = []schemaMergeTest{ right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")), merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), }, - { - name: "right side add default", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")), - }, - { - name: "right side drop default", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), - }, { name: "convergent add", ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")), @@ -299,22 +258,14 @@ var columnDefaultTests = []schemaMergeTest{ }, // one side changes columns, the other inserts rows { + // TODO: this test silently does the wrong thing without erroring + skipNewFmt: true, + skipOldFmt: true, name: "left side column add, right side insert row", ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42)), right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(12)), merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42), row(12, 42)), - skipNewFmt: true, // TODO: this test silently does the wrong thing without erroring - skipOldFmt: true, - }, - { - name: "right side column add, left side insert row", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42), row(11, 42)), - skipNewFmt: true, // TODO: this test silently does the wrong thing without erroring - skipOldFmt: true, }, // both sides change columns and insert rows { @@ -345,13 +296,6 @@ var typeChangeTests = []schemaMergeTest{ right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)), merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)), }, - { - name: "modify column type on the right side", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)), - merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)), - }, { name: "independently modify column type on the both sides", ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)), @@ -379,13 +323,6 @@ var keyChangeTests = []schemaMergeTest{ right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), }, - { - name: "add a trailing primary key column on right side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - }, { name: "add a leading primary key column on left side", ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), @@ -394,26 +331,12 @@ var keyChangeTests = []schemaMergeTest{ merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), }, { - name: "add a leading primary key column on right side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - }, - { - name: "remove a trailing primary key column on left side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - }, - { - name: "remove a trailing primary key column on right side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - skipNewFmt: true, + name: "remove a trailing primary key column on left side", + ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), + left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), + right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))), + merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), + skipFlipOnNewFormat: true, }, { name: "remove a trailing primary key column on both sides", @@ -423,19 +346,12 @@ var keyChangeTests = []schemaMergeTest{ merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), }, { - name: "remove a leading primary key column on left side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - }, - { - name: "remove a leading primary key column on right side", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), - skipNewFmt: true, + name: "remove a leading primary key column on left side", + ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), + left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), + right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))), + merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), + skipFlipOnNewFormat: true, }, { name: "remove a leading primary key column on both sides", @@ -445,20 +361,13 @@ var keyChangeTests = []schemaMergeTest{ merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))), }, { - name: "convert left side to a keyless table", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), - }, - { - name: "convert left side to a keyless table", - ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), - left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), - right: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), - merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), - skipNewFmt: true, - skipOldFmt: true, + skipFlipOnNewFormat: true, + skipFlipOnOldFormat: true, + name: "convert left side to a keyless table", + ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), + left: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), + right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))), + merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))), }, { name: "convert both sides to keyless tables", @@ -515,7 +424,7 @@ var simpleConflictTests = []schemaMergeTest{ ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX a_idx (a))")), right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX key_a (a))")), - // todo: is it allowed to define multiple indexes over the same column? + // todo: it's allowed to have multiple indexes over the same column conflict: true, }, { @@ -542,7 +451,22 @@ var simpleConflictTests = []schemaMergeTest{ } func testSchemaMerge(t *testing.T, tests []schemaMergeTest) { + t.Run("merge left to right", func(t *testing.T) { + testSchemaMergeHelper(t, tests, false) + }) + t.Run("merge right to left", func(t *testing.T) { + testSchemaMergeHelper(t, tests, true) + }) +} + +func testSchemaMergeHelper(t *testing.T, tests []schemaMergeTest, flipSides bool) { for _, test := range tests { + if flipSides { + tmp := test.left + test.left = test.right + test.right = tmp + } + t.Run(test.name, func(t *testing.T) { a, l, r, m := setupSchemaMergeTest(t, test) @@ -552,7 +476,7 @@ func testSchemaMerge(t *testing.T, tests []schemaMergeTest) { eo = eo.WithDeaf(editor.NewInMemDeaf(a.VRW())) // attempt merge before skipping to assert no panics root, _, err := merge.MergeRoots(ctx, l, r, a, rootish{r}, rootish{a}, eo, mo) - maybeSkip(t, a.VRW().Format(), test) + maybeSkip(t, a.VRW().Format(), test, flipSides) require.NoError(t, err) exp, err := m.MapTableHashes(ctx) assert.NoError(t, err) @@ -586,16 +510,16 @@ func setupSchemaMergeTest(t *testing.T, test schemaMergeTest) (anc, left, right, return } -func maybeSkip(t *testing.T, nbf *types.NomsBinFormat, test schemaMergeTest) { +func maybeSkip(t *testing.T, nbf *types.NomsBinFormat, test schemaMergeTest, flipSides bool) { if test.conflict { t.Skip("TODO: test conflict state") } if types.IsFormat_DOLT(nbf) { - if test.skipNewFmt { - t.Skip("") + if test.skipNewFmt || flipSides && test.skipFlipOnNewFormat { + t.Skip() } } else { - if test.skipOldFmt { + if test.skipOldFmt || flipSides && test.skipFlipOnOldFormat { t.Skip() } } From d3c9694e371cf2921e10728eaef136c5a72d1a24 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 21 Apr 2023 13:36:20 -0700 Subject: [PATCH 19/22] Adding basic support for conflict validation and notes about why test cases with indexes and check constraints will not run correctly. --- .../doltcore/merge/schema_merge_test.go | 71 ++++++++++++------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/go/libraries/doltcore/merge/schema_merge_test.go b/go/libraries/doltcore/merge/schema_merge_test.go index d03c5e2c7d..ffd0f63ba4 100644 --- a/go/libraries/doltcore/merge/schema_merge_test.go +++ b/go/libraries/doltcore/merge/schema_merge_test.go @@ -504,26 +504,45 @@ var simpleConflictTests = []schemaMergeTest{ conflict: true, }, { - name: "conflicting index adds: same name and columns, different constraints", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a)) ")), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, UNIQUE INDEX idx (a))")), - conflict: true, + // TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's + // right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt. + // The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently + // drops index and check constraint definitions. + skipNewFmt: true, + skipOldFmt: true, + name: "conflicting index adds: same name and columns, different constraints", + ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), + left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a)) ")), + right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, UNIQUE INDEX idx (a))")), + conflict: true, }, { + // TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's + // right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt. + // The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently + // drops index and check constraint definitions. + skipNewFmt: true, + skipOldFmt: true, + // TODO: multiple indexes can exist for the same column set, so this shouldn't actually be a conflict; + // Dolt does report this as a schema conflict today, but we could merge the two indexes together. name: "conflicting index adds: same column different names", ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX a_idx (a))")), right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX key_a (a))")), - // todo: is it allowed to define multiple indexes over the same column? conflict: true, }, { - name: "conflicting index adds: same name different definitions", - ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), - left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a))")), - right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (b))")), - conflict: true, + // TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's + // right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt. + // The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently + // drops index and check constraint definitions. + skipNewFmt: true, + skipOldFmt: true, + name: "conflicting index adds: same name different definitions", + ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")), + left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a))")), + right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (b))")), + conflict: true, }, { name: "add primary key columns at different key positions on left and right sides", @@ -553,17 +572,23 @@ func testSchemaMerge(t *testing.T, tests []schemaMergeTest) { // attempt merge before skipping to assert no panics root, _, err := merge.MergeRoots(ctx, l, r, a, rootish{r}, rootish{a}, eo, mo) maybeSkip(t, a.VRW().Format(), test) - require.NoError(t, err) - exp, err := m.MapTableHashes(ctx) - assert.NoError(t, err) - act, err := root.MapTableHashes(ctx) - assert.NoError(t, err) - assert.Equal(t, len(exp), len(act)) - for name, addr := range exp { - a, ok := act[name] - assert.True(t, ok) - assert.Equal(t, addr, a) + if test.conflict { + // TODO: Test the conflict error message more deeply + require.Error(t, err) + } else { + require.NoError(t, err) + exp, err := m.MapTableHashes(ctx) + assert.NoError(t, err) + act, err := root.MapTableHashes(ctx) + assert.NoError(t, err) + + assert.Equal(t, len(exp), len(act)) + for name, addr := range exp { + a, ok := act[name] + assert.True(t, ok) + assert.Equal(t, addr, a) + } } }) } @@ -587,9 +612,6 @@ func setupSchemaMergeTest(t *testing.T, test schemaMergeTest) (anc, left, right, } func maybeSkip(t *testing.T, nbf *types.NomsBinFormat, test schemaMergeTest) { - if test.conflict { - t.Skip("TODO: test conflict state") - } if types.IsFormat_DOLT(nbf) { if test.skipNewFmt { t.Skip("") @@ -611,6 +633,7 @@ func sch(definition string) namedSchema { ns := denv.DoltDB.NodeStore() ctx := context.Background() root, _ := doltdb.EmptyRootValue(ctx, vrw, ns) + // TODO: ParseCreateTableStatement silently drops any indexes or check constraints in the definition name, s, err := sqlutil.ParseCreateTableStatement(ctx, root, definition) if err != nil { panic(err) From 18b20bef14ac2c5b69d3f6b8f001e631d9eea886 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 21 Apr 2023 15:30:43 -0700 Subject: [PATCH 20/22] Reverting formatting changes for generated files --- .../dolt/services/eventsapi/v1alpha1/client_event.pb.go | 5 ++--- .../dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go | 1 - .../dolt/services/eventsapi/v1alpha1/event_constants.pb.go | 5 ++--- .../proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go | 5 ++--- .../dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go | 1 - .../dolt/services/remotesapi/v1alpha1/credentials.pb.go | 5 ++--- .../dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go | 1 - 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go index 6e09d77b48..50e349ba74 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event.pb.go @@ -23,13 +23,12 @@ package eventsapi import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go index 8a09ad1cf6..085a9fda2b 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/client_event_grpc.pb.go @@ -24,7 +24,6 @@ package eventsapi import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go b/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go index 3052fb16a1..baf68b07c3 100644 --- a/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go +++ b/go/gen/proto/dolt/services/eventsapi/v1alpha1/event_constants.pb.go @@ -23,11 +23,10 @@ package eventsapi import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go index dde8ed815b..0fc8ae7e15 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore.pb.go @@ -21,12 +21,11 @@ package remotesapi import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go index 28cfc20104..828da30d62 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/chunkstore_grpc.pb.go @@ -22,7 +22,6 @@ package remotesapi import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go index 7c2e689b33..8164b2bb9a 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials.pb.go @@ -21,11 +21,10 @@ package remotesapi import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go index 8ae0dfc1eb..e859388139 100644 --- a/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go +++ b/go/gen/proto/dolt/services/remotesapi/v1alpha1/credentials_grpc.pb.go @@ -22,7 +22,6 @@ package remotesapi import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" From e82727b00862edaa8dc8d84a29959eb4e6f43607 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Mon, 24 Apr 2023 13:43:53 -0700 Subject: [PATCH 21/22] Pointers to interfaces are not useful --- go/cmd/dolt/cli/command.go | 4 ++-- go/cmd/dolt/cli/command_test.go | 2 +- go/cmd/dolt/commands/add.go | 2 +- go/cmd/dolt/commands/admin/setref.go | 2 +- go/cmd/dolt/commands/admin/showroot.go | 2 +- go/cmd/dolt/commands/assist.go | 2 +- go/cmd/dolt/commands/backup.go | 2 +- go/cmd/dolt/commands/blame.go | 2 +- go/cmd/dolt/commands/branch.go | 2 +- go/cmd/dolt/commands/checkout.go | 2 +- go/cmd/dolt/commands/cherry-pick.go | 2 +- go/cmd/dolt/commands/clean.go | 2 +- go/cmd/dolt/commands/clone.go | 2 +- go/cmd/dolt/commands/cnfcmds/cat.go | 2 +- go/cmd/dolt/commands/cnfcmds/resolve.go | 2 +- go/cmd/dolt/commands/commit.go | 2 +- go/cmd/dolt/commands/config.go | 2 +- go/cmd/dolt/commands/credcmds/check.go | 2 +- go/cmd/dolt/commands/credcmds/import.go | 2 +- go/cmd/dolt/commands/credcmds/ls.go | 2 +- go/cmd/dolt/commands/credcmds/new.go | 2 +- go/cmd/dolt/commands/credcmds/rm.go | 2 +- go/cmd/dolt/commands/credcmds/use.go | 2 +- go/cmd/dolt/commands/cvcmds/verify_constraints.go | 2 +- go/cmd/dolt/commands/diff.go | 2 +- go/cmd/dolt/commands/docscmds/diff.go | 2 +- go/cmd/dolt/commands/docscmds/read.go | 2 +- go/cmd/dolt/commands/docscmds/write.go | 2 +- go/cmd/dolt/commands/dump.go | 2 +- go/cmd/dolt/commands/dump_docs.go | 2 +- go/cmd/dolt/commands/fetch.go | 2 +- go/cmd/dolt/commands/filter-branch.go | 2 +- go/cmd/dolt/commands/gc.go | 2 +- go/cmd/dolt/commands/gen_zsh_comp.go | 2 +- go/cmd/dolt/commands/indexcmds/cat.go | 2 +- go/cmd/dolt/commands/indexcmds/ls.go | 2 +- go/cmd/dolt/commands/indexcmds/rebuild.go | 2 +- go/cmd/dolt/commands/init.go | 2 +- go/cmd/dolt/commands/inspect.go | 2 +- go/cmd/dolt/commands/log.go | 2 +- go/cmd/dolt/commands/login.go | 2 +- go/cmd/dolt/commands/ls.go | 2 +- go/cmd/dolt/commands/merge.go | 2 +- go/cmd/dolt/commands/merge_base.go | 2 +- go/cmd/dolt/commands/migrate.go | 2 +- go/cmd/dolt/commands/pull.go | 2 +- go/cmd/dolt/commands/push.go | 2 +- go/cmd/dolt/commands/read_tables.go | 2 +- go/cmd/dolt/commands/remote.go | 2 +- go/cmd/dolt/commands/reset.go | 2 +- go/cmd/dolt/commands/revert.go | 2 +- go/cmd/dolt/commands/roots.go | 2 +- go/cmd/dolt/commands/schcmds/export.go | 2 +- go/cmd/dolt/commands/schcmds/import.go | 2 +- go/cmd/dolt/commands/schcmds/show.go | 2 +- go/cmd/dolt/commands/schcmds/tags.go | 2 +- go/cmd/dolt/commands/schcmds/update-tag.go | 2 +- go/cmd/dolt/commands/send_metrics.go | 2 +- go/cmd/dolt/commands/show.go | 2 +- go/cmd/dolt/commands/sql.go | 2 +- go/cmd/dolt/commands/sqlserver/sqlclient.go | 2 +- go/cmd/dolt/commands/sqlserver/sqlserver.go | 2 +- go/cmd/dolt/commands/stashcmds/clear.go | 2 +- go/cmd/dolt/commands/stashcmds/drop.go | 2 +- go/cmd/dolt/commands/stashcmds/list.go | 2 +- go/cmd/dolt/commands/stashcmds/pop.go | 2 +- go/cmd/dolt/commands/stashcmds/stash.go | 2 +- go/cmd/dolt/commands/status.go | 2 +- go/cmd/dolt/commands/tag.go | 2 +- go/cmd/dolt/commands/tblcmds/cp.go | 2 +- go/cmd/dolt/commands/tblcmds/export.go | 2 +- go/cmd/dolt/commands/tblcmds/import.go | 2 +- go/cmd/dolt/commands/tblcmds/mv.go | 2 +- go/cmd/dolt/commands/tblcmds/rm.go | 2 +- go/cmd/dolt/commands/version.go | 2 +- 75 files changed, 76 insertions(+), 76 deletions(-) diff --git a/go/cmd/dolt/cli/command.go b/go/cmd/dolt/cli/command.go index 03e93e5b3b..0788abd621 100644 --- a/go/cmd/dolt/cli/command.go +++ b/go/cmd/dolt/cli/command.go @@ -64,7 +64,7 @@ type Command interface { // Description returns a description of the command Description() string // Exec executes the command - Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int + Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int // Docs returns the documentation for this command, or nil if it's undocumented Docs() *CommandDocumentation // ArgParser returns the arg parser for this command @@ -169,7 +169,7 @@ func (hc SubCommandHandler) Hidden() bool { return hc.hidden } -func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int { +func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int { if len(args) < 1 && hc.Unspecified == nil { hc.printUsage(commandStr) return 1 diff --git a/go/cmd/dolt/cli/command_test.go b/go/cmd/dolt/cli/command_test.go index 10ef5e2912..8f3f6e7c2c 100644 --- a/go/cmd/dolt/cli/command_test.go +++ b/go/cmd/dolt/cli/command_test.go @@ -68,7 +68,7 @@ func (cmd *trackedCommand) RequiresRepo() bool { return false } -func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *CliContext) int { +func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int { cmd.called = true cmd.cmdStr = commandStr cmd.args = args diff --git a/go/cmd/dolt/commands/add.go b/go/cmd/dolt/commands/add.go index 4942b44614..68d2fa996b 100644 --- a/go/cmd/dolt/commands/add.go +++ b/go/cmd/dolt/commands/add.go @@ -60,7 +60,7 @@ func (cmd AddCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateAddArgParser() helpPr, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, addDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, helpPr) diff --git a/go/cmd/dolt/commands/admin/setref.go b/go/cmd/dolt/commands/admin/setref.go index 536fc42f6f..082955b190 100644 --- a/go/cmd/dolt/commands/admin/setref.go +++ b/go/cmd/dolt/commands/admin/setref.go @@ -64,7 +64,7 @@ func (cmd SetRefCmd) Hidden() bool { // Version displays the version of the running dolt client // Exec executes the command -func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/admin/showroot.go b/go/cmd/dolt/commands/admin/showroot.go index 5b8265b87f..5adb08b5f3 100644 --- a/go/cmd/dolt/commands/admin/showroot.go +++ b/go/cmd/dolt/commands/admin/showroot.go @@ -60,7 +60,7 @@ func (cmd ShowRootCmd) Hidden() bool { // Version displays the version of the running dolt client // Exec executes the command -func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/assist.go b/go/cmd/dolt/commands/assist.go index bd137b2e62..fc224ff552 100755 --- a/go/cmd/dolt/commands/assist.go +++ b/go/cmd/dolt/commands/assist.go @@ -66,7 +66,7 @@ func (a Assist) Hidden() bool { return true } -func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { a.messages = make([]string, 0) apiKey, ok := os.LookupEnv("OPENAI_API_KEY") diff --git a/go/cmd/dolt/commands/backup.go b/go/cmd/dolt/commands/backup.go index cbc7a22c29..7a9e25f0a8 100644 --- a/go/cmd/dolt/commands/backup.go +++ b/go/cmd/dolt/commands/backup.go @@ -105,7 +105,7 @@ func (cmd BackupCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, backupDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/blame.go b/go/cmd/dolt/commands/blame.go index 42373f60a3..057aa75867 100644 --- a/go/cmd/dolt/commands/blame.go +++ b/go/cmd/dolt/commands/blame.go @@ -79,7 +79,7 @@ func (cmd BlameCmd) EventType() eventsapi.ClientEventType { // // When all nodes have blame information, stop iterating through commits and print the blame graph. // Exec executes the command -func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, blameDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/branch.go b/go/cmd/dolt/commands/branch.go index c83164b116..d1ba4b1856 100644 --- a/go/cmd/dolt/commands/branch.go +++ b/go/cmd/dolt/commands/branch.go @@ -98,7 +98,7 @@ func (cmd BranchCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, branchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/checkout.go b/go/cmd/dolt/commands/checkout.go index a335d441c8..59a2d3f206 100644 --- a/go/cmd/dolt/commands/checkout.go +++ b/go/cmd/dolt/commands/checkout.go @@ -78,7 +78,7 @@ func (cmd CheckoutCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateCheckoutArgParser() helpPrt, usagePrt := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkoutDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, helpPrt) diff --git a/go/cmd/dolt/commands/cherry-pick.go b/go/cmd/dolt/commands/cherry-pick.go index c472b71687..8fd0d5c2b7 100644 --- a/go/cmd/dolt/commands/cherry-pick.go +++ b/go/cmd/dolt/commands/cherry-pick.go @@ -71,7 +71,7 @@ func (cmd CherryPickCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command. -func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateCherryPickArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cherryPickDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/clean.go b/go/cmd/dolt/commands/clean.go index 172f80f734..e8bcd6da96 100644 --- a/go/cmd/dolt/commands/clean.go +++ b/go/cmd/dolt/commands/clean.go @@ -65,7 +65,7 @@ func (cmd CleanCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateCleanArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cleanDocContent, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/clone.go b/go/cmd/dolt/commands/clone.go index c19a870fa8..6854d13654 100644 --- a/go/cmd/dolt/commands/clone.go +++ b/go/cmd/dolt/commands/clone.go @@ -81,7 +81,7 @@ func (cmd CloneCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cloneDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cnfcmds/cat.go b/go/cmd/dolt/commands/cnfcmds/cat.go index c043588ebd..cf6a900013 100644 --- a/go/cmd/dolt/commands/cnfcmds/cat.go +++ b/go/cmd/dolt/commands/cnfcmds/cat.go @@ -75,7 +75,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cnfcmds/resolve.go b/go/cmd/dolt/commands/cnfcmds/resolve.go index 33c9080a01..a01d06ff94 100644 --- a/go/cmd/dolt/commands/cnfcmds/resolve.go +++ b/go/cmd/dolt/commands/cnfcmds/resolve.go @@ -88,7 +88,7 @@ func (cmd ResolveCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resDocumentation, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/commit.go b/go/cmd/dolt/commands/commit.go index cfb26d5c48..451bc743b4 100644 --- a/go/cmd/dolt/commands/commit.go +++ b/go/cmd/dolt/commands/commit.go @@ -76,7 +76,7 @@ func (cmd CommitCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { res := performCommit(ctx, commandStr, args, dEnv) if res == 1 { return res diff --git a/go/cmd/dolt/commands/config.go b/go/cmd/dolt/commands/config.go index 3a4d9a1776..7ecb1338a2 100644 --- a/go/cmd/dolt/commands/config.go +++ b/go/cmd/dolt/commands/config.go @@ -116,7 +116,7 @@ func (cmd ConfigCmd) ArgParser() *argparser.ArgParser { // Exec is used by the config command to allow users to view / edit their global and repository local configurations. // Exec executes the command -func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cfgDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/check.go b/go/cmd/dolt/commands/credcmds/check.go index 2c05aaf47b..b848da8bb9 100644 --- a/go/cmd/dolt/commands/credcmds/check.go +++ b/go/cmd/dolt/commands/credcmds/check.go @@ -78,7 +78,7 @@ func (cmd CheckCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/import.go b/go/cmd/dolt/commands/credcmds/import.go index e56b02f8c3..9323a7a655 100644 --- a/go/cmd/dolt/commands/credcmds/import.go +++ b/go/cmd/dolt/commands/credcmds/import.go @@ -89,7 +89,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/ls.go b/go/cmd/dolt/commands/credcmds/ls.go index a0768de9b0..8340c275f5 100644 --- a/go/cmd/dolt/commands/credcmds/ls.go +++ b/go/cmd/dolt/commands/credcmds/ls.go @@ -74,7 +74,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/new.go b/go/cmd/dolt/commands/credcmds/new.go index 1950562bbc..71ee06e538 100644 --- a/go/cmd/dolt/commands/credcmds/new.go +++ b/go/cmd/dolt/commands/credcmds/new.go @@ -70,7 +70,7 @@ func (cmd NewCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, newDocs, ap)) cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/rm.go b/go/cmd/dolt/commands/credcmds/rm.go index 66da291dad..1c61d40fbe 100644 --- a/go/cmd/dolt/commands/credcmds/rm.go +++ b/go/cmd/dolt/commands/credcmds/rm.go @@ -67,7 +67,7 @@ func (cmd RmCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rmDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/credcmds/use.go b/go/cmd/dolt/commands/credcmds/use.go index 1648f2167a..fd16eedd9d 100644 --- a/go/cmd/dolt/commands/credcmds/use.go +++ b/go/cmd/dolt/commands/credcmds/use.go @@ -73,7 +73,7 @@ func (cmd UseCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, useDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/cvcmds/verify_constraints.go b/go/cmd/dolt/commands/cvcmds/verify_constraints.go index 0b437785b1..1a582e9588 100644 --- a/go/cmd/dolt/commands/cvcmds/verify_constraints.go +++ b/go/cmd/dolt/commands/cvcmds/verify_constraints.go @@ -67,7 +67,7 @@ func (cmd VerifyConstraintsCmd) ArgParser() *argparser.ArgParser { return cli.CreateVerifyConstraintsArgParser(cmd.Name()) } -func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, verifyConstraintsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/diff.go b/go/cmd/dolt/commands/diff.go index 920251ad24..46993f2049 100644 --- a/go/cmd/dolt/commands/diff.go +++ b/go/cmd/dolt/commands/diff.go @@ -159,7 +159,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/diff.go b/go/cmd/dolt/commands/docscmds/diff.go index 8b47031dc1..fa163f0131 100644 --- a/go/cmd/dolt/commands/docscmds/diff.go +++ b/go/cmd/dolt/commands/docscmds/diff.go @@ -66,7 +66,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/read.go b/go/cmd/dolt/commands/docscmds/read.go index c6ec28ec98..c68f06791b 100644 --- a/go/cmd/dolt/commands/docscmds/read.go +++ b/go/cmd/dolt/commands/docscmds/read.go @@ -71,7 +71,7 @@ func (cmd UploadCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, uploadDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/docscmds/write.go b/go/cmd/dolt/commands/docscmds/write.go index b4f2634a87..1a9843d5ba 100644 --- a/go/cmd/dolt/commands/docscmds/write.go +++ b/go/cmd/dolt/commands/docscmds/write.go @@ -69,7 +69,7 @@ func (cmd PrintCmd) ArgParser() *argparser.ArgParser { } // Exec implements cli.Command. -func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, printDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/dump.go b/go/cmd/dolt/commands/dump.go index cbf9fc39c9..3f3dc3b139 100644 --- a/go/cmd/dolt/commands/dump.go +++ b/go/cmd/dolt/commands/dump.go @@ -113,7 +113,7 @@ func (cmd DumpCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, dumpDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/dump_docs.go b/go/cmd/dolt/commands/dump_docs.go index c34497b7fe..b66b4eea14 100644 --- a/go/cmd/dolt/commands/dump_docs.go +++ b/go/cmd/dolt/commands/dump_docs.go @@ -72,7 +72,7 @@ func (cmd *DumpDocsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/fetch.go b/go/cmd/dolt/commands/fetch.go index e6090e39cf..53e6b0ea27 100644 --- a/go/cmd/dolt/commands/fetch.go +++ b/go/cmd/dolt/commands/fetch.go @@ -68,7 +68,7 @@ func (cmd FetchCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateFetchArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, fetchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/filter-branch.go b/go/cmd/dolt/commands/filter-branch.go index fc4d619de3..6fcd2ac580 100644 --- a/go/cmd/dolt/commands/filter-branch.go +++ b/go/cmd/dolt/commands/filter-branch.go @@ -96,7 +96,7 @@ func (cmd FilterBranchCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, filterBranchDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/gc.go b/go/cmd/dolt/commands/gc.go index 0187135b9b..78e4a6b1c7 100644 --- a/go/cmd/dolt/commands/gc.go +++ b/go/cmd/dolt/commands/gc.go @@ -81,7 +81,7 @@ func (cmd GarbageCollectionCmd) EventType() eventsapi.ClientEventType { // Version displays the version of the running dolt client // Exec executes the command -func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { var verr errhand.VerboseError ap := cmd.ArgParser() diff --git a/go/cmd/dolt/commands/gen_zsh_comp.go b/go/cmd/dolt/commands/gen_zsh_comp.go index e6d4e6aefc..5cd2430725 100755 --- a/go/cmd/dolt/commands/gen_zsh_comp.go +++ b/go/cmd/dolt/commands/gen_zsh_comp.go @@ -47,7 +47,7 @@ func (z GenZshCompCmd) Description() string { return "Creates a zsh autocomp file for all dolt commands" } -func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := z.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) diff --git a/go/cmd/dolt/commands/indexcmds/cat.go b/go/cmd/dolt/commands/indexcmds/cat.go index c23078490a..acd9c4b7b7 100644 --- a/go/cmd/dolt/commands/indexcmds/cat.go +++ b/go/cmd/dolt/commands/indexcmds/cat.go @@ -79,7 +79,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/indexcmds/ls.go b/go/cmd/dolt/commands/indexcmds/ls.go index c19a684d38..b8a64dd60d 100644 --- a/go/cmd/dolt/commands/indexcmds/ls.go +++ b/go/cmd/dolt/commands/indexcmds/ls.go @@ -55,7 +55,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() ap.TooManyArgsErrorFunc = func(receivedArgs []string) error { args := strings.Join(receivedArgs, ", ") diff --git a/go/cmd/dolt/commands/indexcmds/rebuild.go b/go/cmd/dolt/commands/indexcmds/rebuild.go index fe50050d69..0d52e690cf 100644 --- a/go/cmd/dolt/commands/indexcmds/rebuild.go +++ b/go/cmd/dolt/commands/indexcmds/rebuild.go @@ -58,7 +58,7 @@ func (cmd RebuildCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rebuildDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/init.go b/go/cmd/dolt/commands/init.go index 903dffa6ff..7e8b3d59a6 100644 --- a/go/cmd/dolt/commands/init.go +++ b/go/cmd/dolt/commands/init.go @@ -86,7 +86,7 @@ func (cmd InitCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/inspect.go b/go/cmd/dolt/commands/inspect.go index 1a0c627eea..24209ea2f5 100644 --- a/go/cmd/dolt/commands/inspect.go +++ b/go/cmd/dolt/commands/inspect.go @@ -73,7 +73,7 @@ func (cmd InspectCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/log.go b/go/cmd/dolt/commands/log.go index 2af8db6537..0c54791304 100644 --- a/go/cmd/dolt/commands/log.go +++ b/go/cmd/dolt/commands/log.go @@ -109,7 +109,7 @@ func (cmd LogCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { return cmd.logWithLoggerFunc(ctx, commandStr, args, dEnv) } diff --git a/go/cmd/dolt/commands/login.go b/go/cmd/dolt/commands/login.go index afb08bf406..584d774174 100644 --- a/go/cmd/dolt/commands/login.go +++ b/go/cmd/dolt/commands/login.go @@ -94,7 +94,7 @@ func (cmd LoginCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, loginDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/ls.go b/go/cmd/dolt/commands/ls.go index 15849cabc0..243a671aca 100644 --- a/go/cmd/dolt/commands/ls.go +++ b/go/cmd/dolt/commands/ls.go @@ -78,7 +78,7 @@ func (cmd LsCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/merge.go b/go/cmd/dolt/commands/merge.go index 8ca6d7a146..450c5b6cd9 100644 --- a/go/cmd/dolt/commands/merge.go +++ b/go/cmd/dolt/commands/merge.go @@ -77,7 +77,7 @@ func (cmd MergeCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateMergeArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/merge_base.go b/go/cmd/dolt/commands/merge_base.go index 3b84ab0da0..d2612d61d2 100644 --- a/go/cmd/dolt/commands/merge_base.go +++ b/go/cmd/dolt/commands/merge_base.go @@ -65,7 +65,7 @@ func (cmd MergeBaseCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeBaseDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/migrate.go b/go/cmd/dolt/commands/migrate.go index 07c2a7e1a9..df815c6108 100644 --- a/go/cmd/dolt/commands/migrate.go +++ b/go/cmd/dolt/commands/migrate.go @@ -75,7 +75,7 @@ func (cmd MigrateCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, migrateDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/pull.go b/go/cmd/dolt/commands/pull.go index 1278120e8b..d4b4ff9089 100644 --- a/go/cmd/dolt/commands/pull.go +++ b/go/cmd/dolt/commands/pull.go @@ -68,7 +68,7 @@ func (cmd PullCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreatePullArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pullDocs, ap)) diff --git a/go/cmd/dolt/commands/push.go b/go/cmd/dolt/commands/push.go index b13fd34110..c39650a451 100644 --- a/go/cmd/dolt/commands/push.go +++ b/go/cmd/dolt/commands/push.go @@ -80,7 +80,7 @@ func (cmd PushCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pushDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/read_tables.go b/go/cmd/dolt/commands/read_tables.go index acb9b87e78..53dd66a742 100644 --- a/go/cmd/dolt/commands/read_tables.go +++ b/go/cmd/dolt/commands/read_tables.go @@ -84,7 +84,7 @@ func (cmd ReadTablesCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, readTablesDocs, ap)) diff --git a/go/cmd/dolt/commands/remote.go b/go/cmd/dolt/commands/remote.go index 7619e24c09..8e1bf807d4 100644 --- a/go/cmd/dolt/commands/remote.go +++ b/go/cmd/dolt/commands/remote.go @@ -101,7 +101,7 @@ func (cmd RemoteCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, remoteDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/reset.go b/go/cmd/dolt/commands/reset.go index 29176ddb9a..f074870ac4 100644 --- a/go/cmd/dolt/commands/reset.go +++ b/go/cmd/dolt/commands/reset.go @@ -81,7 +81,7 @@ func (cmd ResetCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateResetArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resetDocContent, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/revert.go b/go/cmd/dolt/commands/revert.go index bfe1479a31..fbc388047e 100644 --- a/go/cmd/dolt/commands/revert.go +++ b/go/cmd/dolt/commands/revert.go @@ -64,7 +64,7 @@ func (cmd RevertCmd) ArgParser() *argparser.ArgParser { } // Exec implements the interface cli.Command. -func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateRevertArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, revertDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/roots.go b/go/cmd/dolt/commands/roots.go index 8586bc964f..48d7535182 100644 --- a/go/cmd/dolt/commands/roots.go +++ b/go/cmd/dolt/commands/roots.go @@ -80,7 +80,7 @@ func (cmd RootsCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/export.go b/go/cmd/dolt/commands/schcmds/export.go index 37cc8b8725..06f822547b 100644 --- a/go/cmd/dolt/commands/schcmds/export.go +++ b/go/cmd/dolt/commands/schcmds/export.go @@ -74,7 +74,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schExportDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/import.go b/go/cmd/dolt/commands/schcmds/import.go index ac6aadf5cf..e08ef2483c 100644 --- a/go/cmd/dolt/commands/schcmds/import.go +++ b/go/cmd/dolt/commands/schcmds/import.go @@ -160,7 +160,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser { // Exec implements the import schema command that will take a file and infer it's schema, and then create a table matching that schema. // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schImportDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/show.go b/go/cmd/dolt/commands/schcmds/show.go index c67430dea5..2f4a67702a 100644 --- a/go/cmd/dolt/commands/schcmds/show.go +++ b/go/cmd/dolt/commands/schcmds/show.go @@ -73,7 +73,7 @@ func (cmd ShowCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblSchemaDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/tags.go b/go/cmd/dolt/commands/schcmds/tags.go index 5d7001beb3..bf9f77dc4d 100644 --- a/go/cmd/dolt/commands/schcmds/tags.go +++ b/go/cmd/dolt/commands/schcmds/tags.go @@ -64,7 +64,7 @@ func (cmd TagsCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblTagsDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/schcmds/update-tag.go b/go/cmd/dolt/commands/schcmds/update-tag.go index c9408bdcc7..e2d0f0647e 100644 --- a/go/cmd/dolt/commands/schcmds/update-tag.go +++ b/go/cmd/dolt/commands/schcmds/update-tag.go @@ -65,7 +65,7 @@ func (cmd UpdateTagCmd) ArgParser() *argparser.ArgParser { return ap } -func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, updateTagDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/send_metrics.go b/go/cmd/dolt/commands/send_metrics.go index 8047854f58..3afbf0ffe7 100644 --- a/go/cmd/dolt/commands/send_metrics.go +++ b/go/cmd/dolt/commands/send_metrics.go @@ -74,7 +74,7 @@ func (cmd SendMetricsCmd) ArgParser() *argparser.ArgParser { // Exec is the implementation of the command that flushes the events to the grpc service // Exec executes the command -func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if dEnv.DoltDB != nil { // see go/cmd/dolt/dolt.go:interceptSendMetrics() cli.PrintErrln("expected DoltEnv without DoltDB") return 1 diff --git a/go/cmd/dolt/commands/show.go b/go/cmd/dolt/commands/show.go index 12d1a6ee0a..9f265f6b44 100644 --- a/go/cmd/dolt/commands/show.go +++ b/go/cmd/dolt/commands/show.go @@ -90,7 +90,7 @@ func (cmd ShowCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, showDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/sql.go b/go/cmd/dolt/commands/sql.go index 8e65c53ca9..79105272d6 100644 --- a/go/cmd/dolt/commands/sql.go +++ b/go/cmd/dolt/commands/sql.go @@ -179,7 +179,7 @@ func (cmd SqlCmd) RequiresRepo() bool { // Exec executes the command // Unlike other commands, sql doesn't set a new working root directly, as the SQL layer updates the working set as // necessary when committing work. -func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlDocs, ap)) diff --git a/go/cmd/dolt/commands/sqlserver/sqlclient.go b/go/cmd/dolt/commands/sqlserver/sqlclient.go index 89853ff06c..a7b59c4ced 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlclient.go +++ b/go/cmd/dolt/commands/sqlserver/sqlclient.go @@ -99,7 +99,7 @@ func (cmd SqlClientCmd) Hidden() bool { return false } -func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlClientDocs, ap)) diff --git a/go/cmd/dolt/commands/sqlserver/sqlserver.go b/go/cmd/dolt/commands/sqlserver/sqlserver.go index 86688c8bb7..fb905c52b2 100644 --- a/go/cmd/dolt/commands/sqlserver/sqlserver.go +++ b/go/cmd/dolt/commands/sqlserver/sqlserver.go @@ -173,7 +173,7 @@ func (cmd SqlServerCmd) RequiresRepo() bool { } // Exec executes the command -func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { controller := NewServerController() newCtx, cancelF := context.WithCancel(context.Background()) go func() { diff --git a/go/cmd/dolt/commands/stashcmds/clear.go b/go/cmd/dolt/commands/stashcmds/clear.go index c7d1f09aec..8c81bd1451 100644 --- a/go/cmd/dolt/commands/stashcmds/clear.go +++ b/go/cmd/dolt/commands/stashcmds/clear.go @@ -63,7 +63,7 @@ func (cmd StashClearCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/drop.go b/go/cmd/dolt/commands/stashcmds/drop.go index bc45613dd3..3873e8bfc1 100644 --- a/go/cmd/dolt/commands/stashcmds/drop.go +++ b/go/cmd/dolt/commands/stashcmds/drop.go @@ -66,7 +66,7 @@ func (cmd StashDropCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/list.go b/go/cmd/dolt/commands/stashcmds/list.go index 03a5983bfc..d28ce12730 100644 --- a/go/cmd/dolt/commands/stashcmds/list.go +++ b/go/cmd/dolt/commands/stashcmds/list.go @@ -63,7 +63,7 @@ func (cmd StashListCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/pop.go b/go/cmd/dolt/commands/stashcmds/pop.go index d52426d05c..cfc6098dde 100644 --- a/go/cmd/dolt/commands/stashcmds/pop.go +++ b/go/cmd/dolt/commands/stashcmds/pop.go @@ -70,7 +70,7 @@ func (cmd StashPopCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/stashcmds/stash.go b/go/cmd/dolt/commands/stashcmds/stash.go index c4cfc446b2..9ceb62d55e 100644 --- a/go/cmd/dolt/commands/stashcmds/stash.go +++ b/go/cmd/dolt/commands/stashcmds/stash.go @@ -88,7 +88,7 @@ func (cmd StashCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { if !dEnv.DoltDB.Format().UsesFlatbuffers() { cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error()) return 1 diff --git a/go/cmd/dolt/commands/status.go b/go/cmd/dolt/commands/status.go index 1d40f1beac..29ddfccaee 100644 --- a/go/cmd/dolt/commands/status.go +++ b/go/cmd/dolt/commands/status.go @@ -61,7 +61,7 @@ func (cmd StatusCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, statusDocs, ap)) cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tag.go b/go/cmd/dolt/commands/tag.go index 51260dc91a..3a0c3fbfe9 100644 --- a/go/cmd/dolt/commands/tag.go +++ b/go/cmd/dolt/commands/tag.go @@ -71,7 +71,7 @@ func (cmd TagCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cli.CreateTagArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tagDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tblcmds/cp.go b/go/cmd/dolt/commands/tblcmds/cp.go index 076fce0eab..4bf349a3f3 100644 --- a/go/cmd/dolt/commands/tblcmds/cp.go +++ b/go/cmd/dolt/commands/tblcmds/cp.go @@ -70,7 +70,7 @@ func (cmd CpCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblCpDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tblcmds/export.go b/go/cmd/dolt/commands/tblcmds/export.go index 89c190d28c..4313abd79a 100644 --- a/go/cmd/dolt/commands/tblcmds/export.go +++ b/go/cmd/dolt/commands/tblcmds/export.go @@ -185,7 +185,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() _, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, exportDocs, ap)) diff --git a/go/cmd/dolt/commands/tblcmds/import.go b/go/cmd/dolt/commands/tblcmds/import.go index df0b21e851..6179b39861 100644 --- a/go/cmd/dolt/commands/tblcmds/import.go +++ b/go/cmd/dolt/commands/tblcmds/import.go @@ -372,7 +372,7 @@ func (cmd ImportCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap)) diff --git a/go/cmd/dolt/commands/tblcmds/mv.go b/go/cmd/dolt/commands/tblcmds/mv.go index 6df76c83ce..62aa686f8c 100644 --- a/go/cmd/dolt/commands/tblcmds/mv.go +++ b/go/cmd/dolt/commands/tblcmds/mv.go @@ -72,7 +72,7 @@ func (cmd MvCmd) EventType() eventsapi.ClientEventType { } // Exec executes the command -func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblMvDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/tblcmds/rm.go b/go/cmd/dolt/commands/tblcmds/rm.go index 02b75bc28f..529ea0d16f 100644 --- a/go/cmd/dolt/commands/tblcmds/rm.go +++ b/go/cmd/dolt/commands/tblcmds/rm.go @@ -66,7 +66,7 @@ func (cmd RmCmd) ArgParser() *argparser.ArgParser { } // Exec executes the command -func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { ap := cmd.ArgParser() help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblRmDocs, ap)) apr := cli.ParseArgsOrDie(ap, args, help) diff --git a/go/cmd/dolt/commands/version.go b/go/cmd/dolt/commands/version.go index 95504598b8..a64d52afbf 100644 --- a/go/cmd/dolt/commands/version.go +++ b/go/cmd/dolt/commands/version.go @@ -60,7 +60,7 @@ func (cmd VersionCmd) ArgParser() *argparser.ArgParser { // Version displays the version of the running dolt client // Exec executes the command -func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx *cli.CliContext) int { +func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int { cli.Println("dolt version", cmd.VersionStr) if dEnv.HasDoltDir() && dEnv.RSLoadErr == nil && !cli.CheckEnvIsValid(dEnv) { From 6cc5e8b4f224293ebb3f0a9ad98a6d5cf11fe698 Mon Sep 17 00:00:00 2001 From: Neil Macneale IV Date: Thu, 20 Apr 2023 12:37:57 -0700 Subject: [PATCH 22/22] Additional pass CliContext pass through missed before --- go/cmd/dolt/cli/command.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/cmd/dolt/cli/command.go b/go/cmd/dolt/cli/command.go index 0788abd621..485476dd3d 100644 --- a/go/cmd/dolt/cli/command.go +++ b/go/cmd/dolt/cli/command.go @@ -183,11 +183,11 @@ func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args [] for _, cmd := range hc.Subcommands { lwrName := strings.ToLower(cmd.Name()) if lwrName == subCommandStr { - return hc.handleCommand(ctx, commandStr+" "+subCommandStr, cmd, args[1:], dEnv) + return hc.handleCommand(ctx, commandStr+" "+subCommandStr, cmd, args[1:], dEnv, cliCtx) } } if hc.Unspecified != nil { - return hc.handleCommand(ctx, commandStr, hc.Unspecified, args, dEnv) + return hc.handleCommand(ctx, commandStr, hc.Unspecified, args, dEnv, cliCtx) } if !isHelp(subCommandStr) { @@ -199,7 +199,7 @@ func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args [] return 0 } -func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string, cmd Command, args []string, dEnv *env.DoltEnv) int { +func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string, cmd Command, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int { cmdRequiresRepo := true if rnrCmd, ok := cmd.(RepoNotRequiredCommand); ok { cmdRequiresRepo = rnrCmd.RequiresRepo() @@ -234,7 +234,7 @@ func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string return 1 } - ret := cmd.Exec(ctx, commandStr, args, dEnv, nil) + ret := cmd.Exec(ctx, commandStr, args, dEnv, cliCtx) if evt != nil { events.GlobalCollector.CloseEventAndAdd(evt)