Merge pull request #6774 from dolthub/steph/pull

migrate dolt pull to use sql queries
This commit is contained in:
stephanie
2023-10-13 15:25:17 -07:00
committed by GitHub
37 changed files with 1269 additions and 729 deletions

View File

@@ -34,7 +34,6 @@ import (
eventsapi "github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi/v1alpha1"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
"github.com/dolthub/dolt/go/libraries/doltcore/merge"
"github.com/dolthub/dolt/go/libraries/utils/argparser"
"github.com/dolthub/dolt/go/store/util/outputpager"
@@ -56,6 +55,8 @@ The second syntax ({{.LessThan}}dolt merge --abort{{.GreaterThan}}) can only be
},
}
var ErrConflictingFlags = "error: Flags '--%s' and '--%s' cannot be used together"
type MergeCmd struct{}
// Name returns the name of the Dolt cli command. This is what is used on the command line to invoke the command
@@ -135,87 +136,29 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,
cli.Println(err.Error())
return 1
}
// check for fast-forward merge
rows, err := sql.RowIterToRows(sqlCtx, schema, rowIter)
if err != nil {
cli.Println("merge finished, but failed to check for fast-forward")
cli.Println(err.Error())
return 0
}
if rows != nil && rows[0][1].(int64) == 1 {
cli.Println("Fast-forward")
}
// calculate merge stats
if !apr.Contains(cli.AbortParam) {
//todo: refs with the `remotes/` prefix will fail to get a hash
headHash, headHashErr := getHashOf(queryist, sqlCtx, "HEAD")
if headHashErr != nil {
cli.Println("merge finished, but failed to get hash of HEAD ref")
cli.Println(headHashErr.Error())
}
mergeHash, mergeHashErr := getHashOf(queryist, sqlCtx, apr.Arg(0))
if mergeHashErr != nil {
cli.Println("merge finished, but failed to get hash of merge ref")
cli.Println(mergeHashErr.Error())
}
headHash, headhHashErr := getHashOf(queryist, sqlCtx, "HEAD")
if headhHashErr != nil {
cli.Println("merge finished, but failed to get hash of HEAD")
cli.Println(headhHashErr.Error())
}
if mergeHashErr == nil && headhHashErr == nil {
cli.Println("Updating", headHash+".."+mergeHash)
}
if apr.Contains(cli.SquashParam) {
cli.Println("Squash commit -- not updating HEAD")
}
if apr.Contains(cli.NoCommitFlag) {
cli.Println("Automatic merge went well; stopped before committing as requested")
return printMergeStats(rows, apr, queryist, sqlCtx, usage, headHash, mergeHash, "HEAD", "STAGED")
}
mergeStats := make(map[string]*merge.MergeStats)
mergeStats, noConflicts, err := calculateMergeConflicts(queryist, sqlCtx, mergeStats)
if err != nil {
cli.Println("merge finished, but could not calculate conflicts")
cli.Println(err.Error())
return 1
}
if noConflicts {
if apr.Contains(cli.NoCommitFlag) {
mergeStats, err = calculateMergeStats(queryist, sqlCtx, mergeStats, "HEAD", "STAGED")
} else {
mergeStats, err = calculateMergeStats(queryist, sqlCtx, mergeStats, "HEAD^1", "HEAD")
}
if err != nil {
if err.Error() == "Already up to date." || err.Error() == "error: unable to get diff summary from HEAD^1 to HEAD: invalid ancestor spec" {
cli.Println("Already up to date.")
return 0
}
cli.Println("merge successful, but could not calculate stats")
cli.Println(err.Error())
return 1
}
}
if !apr.Contains(cli.NoCommitFlag) && !apr.Contains(cli.NoFFParam) {
commit, err := getCommitInfo(queryist, sqlCtx, "HEAD")
if err != nil {
cli.Println("merge finished, but failed to get commit info")
cli.Println(err.Error())
return 0
}
if cli.ExecuteWithStdioRestored != nil {
cli.ExecuteWithStdioRestored(func() {
pager := outputpager.Start()
defer pager.Stop()
PrintCommitInfo(pager, 0, false, "auto", commit)
})
}
}
hasConflicts, hasConstraintViolations := printSuccessStats(mergeStats)
return handleMergeErr(sqlCtx, queryist, nil, hasConflicts, hasConstraintViolations, usage)
return printMergeStats(rows, apr, queryist, sqlCtx, usage, headHash, mergeHash, "HEAD^1", "HEAD")
}
return 0
@@ -224,8 +167,7 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,
// validateDoltMergeArgs checks if the arguments passed to 'dolt merge' are valid
func validateDoltMergeArgs(apr *argparser.ArgParseResults, usage cli.UsagePrinter, cliCtx cli.CliContext) int {
if apr.ContainsAll(cli.SquashParam, cli.NoFFParam) {
cli.PrintErrf("error: Flags '--%s' and '--%s' cannot be used together.\n", cli.SquashParam, cli.NoFFParam)
return 1
return HandleVErrAndExitCode(errhand.BuildDError(ErrConflictingFlags, cli.SquashParam, cli.NoFFParam).Build(), usage)
}
// This command may create a commit, so we need user identity
@@ -256,7 +198,7 @@ func validateDoltMergeArgs(apr *argparser.ArgParseResults, usage cli.UsagePrinte
}
if apr.ContainsAll(cli.CommitFlag, cli.NoCommitFlag) {
return HandleVErrAndExitCode(errhand.BuildDError("cannot define both 'commit' and 'no-commit' flags at the same time").Build(), usage)
return HandleVErrAndExitCode(errhand.BuildDError(ErrConflictingFlags, cli.CommitFlag, cli.NoCommitFlag).Build(), usage)
}
if !apr.Contains(cli.AbortParam) && apr.NArg() == 0 {
usage()
@@ -358,10 +300,84 @@ func constructInterpolatedDoltMergeQuery(apr *argparser.ArgParseResults, cliCtx
return interpolatedQuery, nil
}
// printMergeStats calculates and prints all merge stats and information.
func printMergeStats(result []sql.Row, apr *argparser.ArgParseResults, queryist cli.Queryist, sqlCtx *sql.Context, usage cli.UsagePrinter, headHash, mergeHash, fromRef, toRef string) int {
// dolt_merge returns hash, fast_forward, conflicts and dolt_pull returns fast_forward, conflicts
fastForward := false
if result != nil && len(result) > 0 {
ffIndex := 0
if len(result[0]) == 3 {
ffIndex = 1
}
if ff, ok := result[0][ffIndex].(int64); ok {
fastForward = ff == 1
} else if ff, ok := result[0][ffIndex].(string); ok {
// remote execution returns result as a string
fastForward = ff == "1"
}
}
if fastForward {
cli.Println("Fast-forward")
}
if mergeHash != "" && headHash != "" {
cli.Println("Updating", headHash+".."+mergeHash)
}
if apr.Contains(cli.SquashParam) {
cli.Println("Squash commit -- not updating HEAD")
}
if apr.Contains(cli.NoCommitFlag) {
cli.Println("Automatic merge went well; stopped before committing as requested")
}
mergeStats := make(map[string]*merge.MergeStats)
mergeStats, noConflicts, err := calculateMergeConflicts(queryist, sqlCtx, mergeStats)
if err != nil {
cli.Println("merge finished, but could not calculate conflicts")
cli.Println(err.Error())
return 1
}
if noConflicts {
mergeStats, err = calculateMergeStats(queryist, sqlCtx, mergeStats, fromRef, toRef)
if err != nil {
if err == doltdb.ErrUpToDate || err.Error() == "error: unable to get diff summary from HEAD^1 to HEAD: invalid ancestor spec" {
cli.Println(doltdb.ErrUpToDate.Error())
return 0
}
cli.Println("merge successful, but could not calculate stats")
cli.Println(err.Error())
return 1
}
}
if !apr.Contains(cli.NoCommitFlag) && !apr.Contains(cli.NoFFParam) && !fastForward {
commit, err := getCommitInfo(queryist, sqlCtx, "HEAD")
if err != nil {
cli.Println("merge finished, but failed to get commit info")
cli.Println(err.Error())
return 0
}
if cli.ExecuteWithStdioRestored != nil {
cli.ExecuteWithStdioRestored(func() {
pager := outputpager.Start()
defer pager.Stop()
PrintCommitInfo(pager, 0, false, "auto", commit)
})
}
}
hasConflicts, hasConstraintViolations := printSuccessStats(mergeStats)
return handleMergeErr(sqlCtx, queryist, nil, hasConflicts, hasConstraintViolations, usage)
}
// calculateMergeConflicts calculates the count of conflicts that occurred during the merge. Returns a map of table name to MergeStats,
// a bool indicating whether there were any conflicts, and a bool indicating whether calculation was successful.
func calculateMergeConflicts(queryist cli.Queryist, sqlCtx *sql.Context, mergeStats map[string]*merge.MergeStats) (map[string]*merge.MergeStats, bool, error) {
dataConflicts, err := GetRowsForSql(queryist, sqlCtx, "SELECT * FROM dolt_conflicts")
dataConflicts, err := GetRowsForSql(queryist, sqlCtx, "SELECT `table`, num_conflicts FROM dolt_conflicts")
if err != nil {
return nil, false, err
}
@@ -374,7 +390,7 @@ func calculateMergeConflicts(queryist cli.Queryist, sqlCtx *sql.Context, mergeSt
}
}
schemaConflicts, err := GetRowsForSql(queryist, sqlCtx, "SELECT * FROM dolt_schema_conflicts")
schemaConflicts, err := GetRowsForSql(queryist, sqlCtx, "SELECT table_name FROM dolt_schema_conflicts")
if err != nil {
return nil, false, err
}
@@ -387,7 +403,7 @@ func calculateMergeConflicts(queryist cli.Queryist, sqlCtx *sql.Context, mergeSt
}
}
constraintViolations, err := GetRowsForSql(queryist, sqlCtx, "SELECT * FROM dolt_constraint_violations")
constraintViolations, err := GetRowsForSql(queryist, sqlCtx, "SELECT `table`, num_violations FROM dolt_constraint_violations")
if err != nil {
return nil, false, err
}
@@ -450,7 +466,7 @@ func calculateMergeStats(queryist cli.Queryist, sqlCtx *sql.Context, mergeStats
}
if allUnmodified {
return nil, errors.New("Already up to date.")
return nil, doltdb.ErrUpToDate
}
// get row stats
@@ -463,72 +479,6 @@ func calculateMergeStats(queryist cli.Queryist, sqlCtx *sql.Context, mergeStats
return mergeStats, nil
}
func validateMergeSpec(ctx context.Context, spec *merge.MergeSpec) errhand.VerboseError {
if spec.HeadH == spec.MergeH {
//TODO - why is this different for merge/pull?
// cli.Println("Already up to date.")
cli.Println("Everything up-to-date.")
return nil
}
cli.Println("Updating", spec.HeadH.String()+".."+spec.MergeH.String())
if spec.Squash {
cli.Println("Squash commit -- not updating HEAD")
}
if len(spec.StompedTblNames) != 0 {
bldr := errhand.BuildDError("error: Your local changes to the following tables would be overwritten by merge:")
for _, tName := range spec.StompedTblNames {
bldr.AddDetails(tName)
}
bldr.AddDetails("Please commit your changes before you merge.")
return bldr.Build()
}
if ok, err := spec.HeadC.CanFastForwardTo(ctx, spec.MergeC); ok {
ancRoot, err := spec.HeadC.GetRootValue(ctx)
if err != nil {
return errhand.VerboseErrorFromError(err)
}
mergedRoot, err := spec.MergeC.GetRootValue(ctx)
if err != nil {
return errhand.VerboseErrorFromError(err)
}
if _, err := merge.MayHaveConstraintViolations(ctx, ancRoot, mergedRoot); err != nil {
return errhand.VerboseErrorFromError(err)
}
if !spec.NoFF {
cli.Println("Fast-forward")
}
} else if err == doltdb.ErrUpToDate || err == doltdb.ErrIsAhead {
cli.Println("Already up to date.")
}
return nil
}
func abortMerge(ctx context.Context, doltEnv *env.DoltEnv) errhand.VerboseError {
roots, err := doltEnv.Roots(ctx)
if err != nil {
return errhand.VerboseErrorFromError(err)
}
roots, err = actions.CheckoutAllTables(ctx, roots)
if err == nil {
err = doltEnv.AbortMerge(ctx)
if err == nil {
return nil
}
}
err = doltEnv.UpdateWorkingRoot(ctx, roots.Working)
if err != nil {
return errhand.VerboseErrorFromError(err)
}
return errhand.BuildDError("fatal: failed to revert changes").AddCause(err).Build()
}
// printSuccessStats returns whether there are conflicts or constraint violations.
func printSuccessStats(tblToStats map[string]*merge.MergeStats) (conflicts bool, constraintViolations bool) {
printModifications(tblToStats)
@@ -690,14 +640,17 @@ func handleMergeErr(sqlCtx *sql.Context, queryist cli.Queryist, mergeErr error,
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Fix conflicts and constraint violations and then commit the result.\n"+
"Use 'dolt conflicts' to investigate and resolve conflicts.\n", unmergedCnt)
return 1
} else if hasConflicts {
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Use 'dolt conflicts' to investigate and resolve conflicts.\n", unmergedCnt)
return 1
} else if hasConstraintViolations {
cli.Printf("Automatic merge failed; %d table(s) are unmerged.\n"+
"Fix constraint violations and then commit the result.\n"+
"Constraint violations for the working set may be viewed using the 'dolt_constraint_violations' system table.\n"+
"They may be queried and removed per-table using the 'dolt_constraint_violations_TABLENAME' system table.\n", unmergedCnt)
return 1
}
if mergeErr != nil {
@@ -714,149 +667,3 @@ func handleMergeErr(sqlCtx *sql.Context, queryist cli.Queryist, mergeErr error,
return 0
}
// performMerge applies a merge spec, potentially fast-forwarding the current branch HEAD, and returns a MergeStats object.
// If the merge can be applied as a fast-forward merge, no commit is needed.
// If the merge is a fast-forward merge, but --no-ff has been supplied, the ExecNoFFMerge function will call
// commit after merging. If the merge is not fast-forward, the --no-commit flag is not defined, and there are
// no conflicts and/or constraint violations, this function will call commit after merging.
// TODO: forcing a commit with a constraint violation should warn users that subsequent
//
// FF merges will not surface constraint violations on their own; constraint verify --all
// is required to reify violations.
func performMerge(ctx context.Context, sqlCtx *sql.Context, queryist cli.Queryist, dEnv *env.DoltEnv, spec *merge.MergeSpec, suggestedMsg string, cliCtx cli.CliContext) (map[string]*merge.MergeStats, error) {
if ok, err := spec.HeadC.CanFastForwardTo(ctx, spec.MergeC); err != nil && !errors.Is(err, doltdb.ErrUpToDate) {
return nil, err
} else if ok {
if spec.NoFF {
return executeNoFFMergeAndCommit(ctx, sqlCtx, queryist, dEnv, spec, suggestedMsg, cliCtx)
}
return nil, merge.ExecuteFFMerge(ctx, dEnv, spec)
}
return executeMergeAndCommit(ctx, sqlCtx, queryist, dEnv, spec, suggestedMsg, cliCtx)
}
func executeNoFFMergeAndCommit(ctx context.Context, sqlCtx *sql.Context, queryist cli.Queryist, dEnv *env.DoltEnv, spec *merge.MergeSpec, suggestedMsg string, cliCtx cli.CliContext) (map[string]*merge.MergeStats, error) {
tblToStats, err := merge.ExecNoFFMerge(ctx, dEnv, spec)
if err != nil {
return tblToStats, err
}
if spec.NoCommit {
cli.Println("Automatic merge went well; stopped before committing as requested")
return tblToStats, nil
}
// Reload roots since the above method writes new values to the working set
roots, err := dEnv.Roots(ctx)
if err != nil {
return tblToStats, err
}
ws, err := dEnv.WorkingSet(ctx)
if err != nil {
return tblToStats, err
}
var mergeParentCommits []*doltdb.Commit
if ws.MergeActive() {
mergeParentCommits = []*doltdb.Commit{ws.MergeState().Commit()}
}
msg, err := getCommitMsgForMerge(sqlCtx, queryist, suggestedMsg, spec.NoEdit, cliCtx)
if err != nil {
return tblToStats, err
}
pendingCommit, err := actions.GetCommitStaged(ctx, roots, ws, mergeParentCommits, dEnv.DbData().Ddb, actions.CommitStagedProps{
Message: msg,
Date: spec.Date,
Force: spec.Force,
Name: spec.Name,
Email: spec.Email,
})
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
if err != nil {
return tblToStats, err
}
wsHash, err := ws.HashOf()
_, err = dEnv.DoltDB.CommitWithWorkingSet(
ctx,
headRef,
ws.Ref(),
pendingCommit,
ws.WithStagedRoot(pendingCommit.Roots.Staged).WithWorkingRoot(pendingCommit.Roots.Working).ClearMerge(),
wsHash,
dEnv.NewWorkingSetMeta(msg),
nil,
)
if err != nil {
return tblToStats, fmt.Errorf("%w; failed to commit", err)
}
return tblToStats, err
}
func executeMergeAndCommit(ctx context.Context, sqlCtx *sql.Context, queryist cli.Queryist, dEnv *env.DoltEnv, spec *merge.MergeSpec, suggestedMsg string, cliCtx cli.CliContext) (map[string]*merge.MergeStats, error) {
tblToStats, err := merge.ExecuteMerge(sqlCtx, dEnv, spec)
if err != nil {
return tblToStats, err
}
if hasConflictOrViolations(tblToStats) {
return tblToStats, nil
}
if spec.NoCommit {
cli.Println("Automatic merge went well; stopped before committing as requested")
return tblToStats, nil
}
msg, err := getCommitMsgForMerge(sqlCtx, queryist, suggestedMsg, spec.NoEdit, cliCtx)
if err != nil {
return tblToStats, err
}
author := fmt.Sprintf("%s <%s>", spec.Name, spec.Email)
res, skipped := performCommit(ctx, "commit", []string{"-m", msg, "--author", author}, cliCtx, dEnv)
if res != 0 || skipped {
return nil, fmt.Errorf("dolt commit failed after merging")
}
return tblToStats, nil
}
// getCommitMsgForMerge returns user defined message if exists; otherwise, get the commit message from editor.
func getCommitMsgForMerge(
sqlCtx *sql.Context,
queryist cli.Queryist,
suggestedMsg string,
noEdit bool,
cliCtx cli.CliContext,
) (string, error) {
msg, err := getCommitMessageFromEditor(sqlCtx, queryist, suggestedMsg, "", noEdit, cliCtx)
if err != nil {
return msg, err
}
if msg == "" {
return msg, fmt.Errorf("error: Empty commit message.\n" +
"Not committing merge; use 'dolt commit' to complete the merge.")
}
return msg, nil
}
// hasConflictOrViolations checks for conflicts or constraint violation regardless of a table being modified
func hasConflictOrViolations(tblToStats map[string]*merge.MergeStats) bool {
for _, tblStats := range tblToStats {
if tblStats.HasArtifacts() {
return true
}
}
return false
}

View File

@@ -18,19 +18,20 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"
"github.com/dolthub/go-mysql-server/sql"
"github.com/gocraft/dbr/v2"
"github.com/gocraft/dbr/v2/dialect"
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
eventsapi "github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi/v1alpha1"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
"github.com/dolthub/dolt/go/libraries/doltcore/merge"
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
"github.com/dolthub/dolt/go/libraries/utils/argparser"
"github.com/dolthub/dolt/go/store/datas"
"github.com/dolthub/dolt/go/store/util/outputpager"
)
var pullDocs = cli.CommandDocumentationContent{
@@ -80,6 +81,22 @@ func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, d
verr := errhand.VerboseErrorFromError(actions.ErrInvalidPullArgs)
return HandleVErrAndExitCode(verr, usage)
}
if apr.ContainsAll(cli.CommitFlag, cli.NoCommitFlag) {
verr := errhand.VerboseErrorFromError(errors.New(fmt.Sprintf(ErrConflictingFlags, cli.CommitFlag, cli.NoCommitFlag)))
return HandleVErrAndExitCode(verr, usage)
}
if apr.ContainsAll(cli.SquashParam, cli.NoFFParam) {
verr := errhand.VerboseErrorFromError(errors.New(fmt.Sprintf(ErrConflictingFlags, cli.SquashParam, cli.NoFFParam)))
return HandleVErrAndExitCode(verr, usage)
}
// This command may create a commit, so we need user identity
if !cli.CheckUserNameAndEmail(cliCtx.Config()) {
bdr := errhand.BuildDError("Could not determine name and/or email.")
bdr.AddDetails("Log into DoltHub: dolt login")
bdr.AddDetails("OR add name to config: dolt config [--global|--local] --add %[1]s \"FIRST LAST\"", env.UserNameKey)
bdr.AddDetails("OR add email to config: dolt config [--global|--local] --add %[1]s \"EMAIL_ADDRESS\"", env.UserEmailKey)
return HandleVErrAndExitCode(bdr.Build(), usage)
}
queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(ctx)
if err != nil {
@@ -90,192 +107,196 @@ func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, d
defer closeFunc()
}
var remoteName, remoteRefName string
if apr.NArg() == 1 {
remoteName = apr.Arg(0)
} else if apr.NArg() == 2 {
remoteName = apr.Arg(0)
remoteRefName = apr.Arg(1)
}
if dEnv.IsLocked() {
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(env.ErrActiveServerLock.New(dEnv.LockFile())), help)
}
var verr errhand.VerboseError
dEnv.UserPassConfig, verr = getRemoteUserAndPassConfig(apr)
if verr != nil {
return HandleVErrAndExitCode(verr, usage)
}
remoteOnly := apr.NArg() == 1
pullSpec, err := env.NewPullSpec(
ctx,
dEnv.RepoStateReader(),
remoteName,
remoteRefName,
remoteOnly,
env.WithSquash(apr.Contains(cli.SquashParam)),
env.WithNoFF(apr.Contains(cli.NoFFParam)),
env.WithNoCommit(apr.Contains(cli.NoCommitFlag)),
env.WithNoEdit(apr.Contains(cli.NoEditFlag)),
env.WithForce(apr.Contains(cli.ForceFlag)),
)
query, err := constructInterpolatedDoltPullQuery(apr)
if err != nil {
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
err = pullHelper(ctx, sqlCtx, queryist, dEnv, pullSpec, cliCtx)
if err != nil {
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
errChan := make(chan error)
go func() {
defer close(errChan)
// allows pulls (merges) that create conflicts to stick
_, _, err = queryist.Query(sqlCtx, "set @@dolt_force_transaction_commit = 1")
if err != nil {
errChan <- err
return
}
// save current head for diff summaries after pull
headHash, err := getHashOf(queryist, sqlCtx, "HEAD")
if err != nil {
cli.Println("failed to get hash of HEAD, pull not started")
errChan <- err
}
// pullHelper splits pull into fetch, prepare merge, and merge to interleave printing
func pullHelper(
ctx context.Context,
sqlCtx *sql.Context,
queryist cli.Queryist,
dEnv *env.DoltEnv,
pullSpec *env.PullSpec,
cliCtx cli.CliContext,
) error {
srcDB, err := pullSpec.Remote.GetRemoteDBWithoutCaching(ctx, dEnv.DoltDB.ValueReadWriter().Format(), dEnv)
if err != nil {
return fmt.Errorf("failed to get remote db; %w", err)
}
schema, rowIter, err := queryist.Query(sqlCtx, query)
if err != nil {
errChan <- err
return
}
// if merge is called with '--no-commit', we need to commit the sql transaction or the staged changes will be lost
_, _, err = queryist.Query(sqlCtx, "COMMIT")
if err != nil {
errChan <- err
return
}
rows, err := sql.RowIterToRows(sqlCtx, schema, rowIter)
if err != nil {
errChan <- err
return
}
// Fetch all references
branchRefs, err := srcDB.GetHeadRefs(ctx)
if err != nil {
return fmt.Errorf("%w: %s", env.ErrFailedToReadDb, err.Error())
}
remoteHash, remoteRef, err := getRemoteHashForPull(apr, sqlCtx, queryist)
if err != nil {
cli.Println("pull finished, but failed to get hash of remote ref")
cli.Println(err.Error())
}
_, hasBranch, err := srcDB.HasBranch(ctx, pullSpec.Branch.GetPath())
if err != nil {
return err
}
if !hasBranch {
return fmt.Errorf("branch %q not found on remote", pullSpec.Branch.GetPath())
}
// Go through every reference and every branch in each reference
for _, rs := range pullSpec.RefSpecs {
rsSeen := false // track invalid refSpecs
for _, branchRef := range branchRefs {
remoteTrackRef := rs.DestRef(branchRef)
if remoteTrackRef == nil {
continue
if apr.Contains(cli.ForceFlag) {
if remoteHash != "" && headHash != "" {
cli.Println("Updating", headHash+".."+remoteHash)
}
rsSeen = true
tmpDir, err := dEnv.TempTableFilesDir()
commit, err := getCommitInfo(queryist, sqlCtx, "HEAD")
if err != nil {
return err
cli.Println("pull finished, but failed to get commit info")
cli.Println(err.Error())
return
}
srcDBCommit, err := actions.FetchRemoteBranch(ctx, tmpDir, pullSpec.Remote, srcDB, dEnv.DoltDB, branchRef, buildProgStarter(downloadLanguage), stopProgFuncs)
if err != nil {
return err
if cli.ExecuteWithStdioRestored != nil {
cli.ExecuteWithStdioRestored(func() {
pager := outputpager.Start()
defer pager.Stop()
PrintCommitInfo(pager, 0, false, "auto", commit)
})
}
err = dEnv.DoltDB.FastForward(ctx, remoteTrackRef, srcDBCommit)
if errors.Is(err, datas.ErrMergeNeeded) {
// If the remote tracking branch has diverged from the local copy, we just overwrite it
h, err := srcDBCommit.HashOf()
if err != nil {
return err
}
err = dEnv.DoltDB.SetHead(ctx, remoteTrackRef, h)
if err != nil {
return err
}
} else if err != nil {
return fmt.Errorf("fetch failed: %w", err)
} else {
var success int
if apr.Contains(cli.NoCommitFlag) {
success = printMergeStats(rows, apr, queryist, sqlCtx, usage, headHash, remoteHash, "HEAD", "STAGED")
} else {
success = printMergeStats(rows, apr, queryist, sqlCtx, usage, headHash, remoteHash, "HEAD", remoteRef)
}
// Merge iff branch is current branch and there is an upstream set (pullSpec.Branch is set to nil if there is no upstream)
if branchRef != pullSpec.Branch {
continue
}
t := datas.CommitterDate()
roots, err := dEnv.Roots(ctx)
if err != nil {
return err
}
name, email, configErr := env.GetNameAndEmail(dEnv.Config)
// If the name and email aren't set we can set them to empty values for now. This is only valid for ff
// merges which we detect later.
if configErr != nil {
if pullSpec.NoFF {
return configErr
}
name, email = "", ""
}
// Begin merge of working and head with the remote head
mergeSpec, err := merge.NewMergeSpec(ctx, dEnv.RepoStateReader(), dEnv.DoltDB, roots, name, email, remoteTrackRef.String(), t, merge.WithPullSpecOpts(pullSpec))
if err != nil {
return err
}
if mergeSpec == nil {
return nil
}
// If configurations are not set and a ff merge are not possible throw an error.
if configErr != nil {
canFF, err := mergeSpec.HeadC.CanFastForwardTo(ctx, mergeSpec.MergeC)
if err != nil && err != doltdb.ErrUpToDate {
return err
}
if !canFF {
return configErr
}
}
err = validateMergeSpec(ctx, mergeSpec)
if err != nil {
return err
}
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
if err != nil {
return err
}
suggestedMsg := fmt.Sprintf(
"Merge branch '%s' of %s into %s",
pullSpec.Branch.GetPath(),
pullSpec.Remote.Url,
headRef.GetPath(),
)
tblStats, err := performMerge(ctx, sqlCtx, queryist, dEnv, mergeSpec, suggestedMsg, cliCtx)
printSuccessStats(tblStats)
if err != nil {
return err
if success == 1 {
errChan <- errors.New(" ") //return a non-nil error for the correct exit code but no further messages to print
return
}
}
if !rsSeen {
return fmt.Errorf("%w: '%s'", ref.ErrInvalidRefSpec, rs.GetRemRefToLocal())
}()
spinner := TextSpinner{}
cli.Print(spinner.next() + " Pulling...")
defer func() {
cli.DeleteAndPrint(len(" Pulling...")+1, "")
}()
for {
select {
case err := <-errChan:
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
case <-ctx.Done():
if ctx.Err() != nil {
switch ctx.Err() {
case context.DeadlineExceeded:
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(errors.New("timeout exceeded")), usage)
case context.Canceled:
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(errors.New("pull cancelled by force")), usage)
default:
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(errors.New("error cancelling context: "+ctx.Err().Error())), usage)
}
}
return HandleVErrAndExitCode(nil, usage)
case <-time.After(time.Millisecond * 50):
cli.DeleteAndPrint(len(" Pulling...")+1, spinner.next()+" Pulling...")
}
}
if err != nil {
return err
}
tmpDir, err := dEnv.TempTableFilesDir()
if err != nil {
return err
}
err = actions.FetchFollowTags(ctx, tmpDir, srcDB, dEnv.DoltDB, buildProgStarter(downloadLanguage), stopProgFuncs)
if err != nil {
return err
}
return nil
}
// constructInterpolatedDoltPullQuery constructs the sql query necessary to call the DOLT_PULL() function.
// Also interpolates this query to prevent sql injection.
func constructInterpolatedDoltPullQuery(apr *argparser.ArgParseResults) (string, error) {
var params []interface{}
var args []string
for _, arg := range apr.Args {
args = append(args, "?")
params = append(params, arg)
}
if apr.Contains(cli.SquashParam) {
args = append(args, "'--squash'")
}
if apr.Contains(cli.NoFFParam) {
args = append(args, "'--no-ff'")
}
if apr.Contains(cli.ForceFlag) {
args = append(args, "'--force'")
}
if apr.Contains(cli.CommitFlag) {
args = append(args, "'--commit'")
}
if apr.Contains(cli.NoCommitFlag) {
args = append(args, "'--no-commit'")
}
if apr.Contains(cli.NoEditFlag) {
args = append(args, "'--no-edit'")
}
if user, hasUser := apr.GetValue(cli.UserFlag); hasUser {
args = append(args, "'--user'")
args = append(args, "?")
params = append(params, user)
}
query := "call dolt_pull(" + strings.Join(args, ", ") + ")"
interpolatedQuery, err := dbr.InterpolateForDialect(query, params, dialect.MySQL)
if err != nil {
return "", err
}
return interpolatedQuery, nil
}
// getRemoteHashForPull gets the hash of the remote branch being merged in and the ref to the remote head
func getRemoteHashForPull(apr *argparser.ArgParseResults, sqlCtx *sql.Context, queryist cli.Queryist) (remoteHash, remoteRef string, err error) {
var remote, branch string
if apr.NArg() < 2 {
if apr.NArg() == 0 {
remote, err = getDefaultRemote(sqlCtx, queryist)
if err != nil {
return "", "", err
}
} else {
remote = apr.Args[0]
}
rows, err := GetRowsForSql(queryist, sqlCtx, "select name from dolt_remote_branches")
if err != nil {
return "", "", err
}
for _, row := range rows {
ref := row[0].(string)
if ref == "remotes/"+remote+"/main" {
branch = "main"
break
}
}
if branch == "" {
ref := rows[0][0].(string)
branch = strings.TrimPrefix(ref, "remotes/"+remote+"/")
}
} else {
remote = apr.Args[0]
branch = apr.Args[1]
}
if remote == "" || branch == "" {
return "", "", errors.New("pull finished successfully but remote and/or branch provided is empty")
}
remoteHash, err = getHashOf(queryist, sqlCtx, remote+"/"+branch)
if err != nil {
return "", "", err
}
return remoteHash, remote + "/" + branch, nil
}

View File

@@ -199,7 +199,7 @@ func getDefaultRemote(sqlCtx *sql.Context, queryist cli.Queryist) (string, error
return "origin", nil
}
}
return "", env.ErrCantDetermineDefault
return rows[0][0].(string), nil
}
// processFetchSpecs takes a string of fetch specs and returns the destination ref and remote ref

View File

@@ -42,7 +42,7 @@ var ErrAlreadyOnWorkspace = errors.New("Already on workspace")
var ErrNomsIO = errors.New("error reading from or writing to noms")
var ErrUpToDate = errors.New("up to date")
var ErrUpToDate = errors.New("Everything up-to-date")
var ErrIsAhead = errors.New("cannot fast forward from a to b. a is ahead of b already")
var ErrIsBehind = errors.New("cannot reverse from b to a. b is a is behind a already")

View File

@@ -81,16 +81,6 @@ func WithSquash(squash bool) MergeSpecOpt {
}
}
func WithPullSpecOpts(pullSpec *env.PullSpec) MergeSpecOpt {
return func(ms *MergeSpec) {
ms.NoEdit = pullSpec.NoEdit
ms.NoCommit = pullSpec.NoCommit
ms.Force = pullSpec.Force
ms.NoFF = pullSpec.NoFF
ms.Squash = pullSpec.Squash
}
}
// NewMergeSpec returns a MergeSpec with the arguments provided.
func NewMergeSpec(
ctx context.Context,

View File

@@ -241,7 +241,7 @@ func performMerge(
return ws, "", noConflictsOrViolations, threeWayMerge, sql.ErrDatabaseNotFound.New(dbName)
}
ws, err = executeMerge(ctx, sess, dbName, spec.Squash, spec.HeadC, spec.MergeC, spec.MergeCSpecStr, ws, dbState.EditOpts(), spec.WorkingDiffs)
ws, err = executeMerge(ctx, sess, dbName, spec.Squash, spec.Force, spec.HeadC, spec.MergeC, spec.MergeCSpecStr, ws, dbState.EditOpts(), spec.WorkingDiffs)
if err == doltdb.ErrUnresolvedConflictsOrViolations {
// if there are unresolved conflicts, write the resulting working set back to the session and return an
// error message
@@ -265,7 +265,11 @@ func performMerge(
var commit string
if !noCommit {
author := fmt.Sprintf("%s <%s>", spec.Name, spec.Email)
commit, _, err = doDoltCommit(ctx, []string{"-m", msg, "--author", author})
args := []string{"-m", msg, "--author", author}
if spec.Force {
args = append(args, "--force")
}
commit, _, err = doDoltCommit(ctx, args)
if err != nil {
return ws, commit, noConflictsOrViolations, threeWayMerge, fmt.Errorf("dolt_commit failed")
}
@@ -316,6 +320,7 @@ func executeMerge(
sess *dsess.DoltSession,
dbName string,
squash bool,
force bool,
head, cm *doltdb.Commit,
cmSpec string,
ws *doltdb.WorkingSet,
@@ -333,7 +338,7 @@ func executeMerge(
return nil, err
}
}
return mergeRootToWorking(ctx, sess, dbName, squash, ws, result, workingDiffs, cm, cmSpec)
return mergeRootToWorking(ctx, sess, dbName, squash, force, ws, result, workingDiffs, cm, cmSpec)
}
func executeFFMerge(ctx *sql.Context, dbName string, squash bool, ws *doltdb.WorkingSet, dbData env.DbData, cm2 *doltdb.Commit, spec *merge.MergeSpec) (*doltdb.WorkingSet, error) {
@@ -399,7 +404,7 @@ func executeNoFFMerge(
}
result := &merge.Result{Root: mergeRoot, Stats: make(map[string]*merge.MergeStats)}
ws, err = mergeRootToWorking(ctx, dSess, dbName, false, ws, result, spec.WorkingDiffs, spec.MergeC, spec.MergeCSpecStr)
ws, err = mergeRootToWorking(ctx, dSess, dbName, false, spec.Force, ws, result, spec.WorkingDiffs, spec.MergeC, spec.MergeCSpecStr)
if err != nil {
// This error is recoverable, so we return a working set value along with the error
return ws, nil, err
@@ -515,7 +520,7 @@ func mergeRootToWorking(
ctx *sql.Context,
dSess *dsess.DoltSession,
dbName string,
squash bool,
squash, force bool,
ws *doltdb.WorkingSet,
merged *merge.Result,
workingDiffs map[string]hash.Hash,
@@ -538,7 +543,7 @@ func mergeRootToWorking(
}
ws = ws.WithWorkingRoot(working)
if !merged.HasMergeArtifacts() {
if !merged.HasMergeArtifacts() && !force {
ws = ws.WithStagedRoot(staged)
}
@@ -547,7 +552,7 @@ func mergeRootToWorking(
return nil, err
}
if merged.HasMergeArtifacts() {
if merged.HasMergeArtifacts() && !force {
// this error is recoverable in-session, so we return the new ws along with the error
return ws, doltdb.ErrUnresolvedConflictsOrViolations
}

View File

@@ -406,7 +406,7 @@ teardown() {
dolt commit -m "added conflicting test row"
dolt checkout main
run dolt merge test-branch --no-commit
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
run dolt conflicts cat test
[ "$status" -eq 0 ]
@@ -450,7 +450,7 @@ teardown() {
dolt commit -m "added conflicting test row"
dolt checkout main
run dolt merge test-branch --no-commit
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
run dolt conflicts cat test
[ "$status" -eq 0 ]
@@ -492,7 +492,9 @@ teardown() {
dolt add test
dolt commit -m "added conflicting test row"
dolt checkout main
dolt merge test-branch
run dolt merge test-branch
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
run dolt sql -q "select * from test"
[[ "$output" =~ \|[[:space:]]+5 ]] || false
run dolt conflicts cat test
@@ -520,7 +522,9 @@ teardown() {
dolt add test
dolt commit -m "added conflicting test row"
dolt checkout main
dolt merge test-branch
run dolt merge test-branch
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
run dolt conflicts resolve --theirs test
[ "$status" -eq 0 ]
[ "$output" = "" ]
@@ -541,7 +545,9 @@ teardown() {
dolt add test
dolt commit -m "added conflicting test row"
dolt checkout main
dolt merge test-branch
run dolt merge test-branch
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--theirs', 'test')"
[ "$status" -eq 0 ]
run dolt sql -q "select * from test"

View File

@@ -392,7 +392,9 @@ SQL
# remove special characters (color)
shaparent2=$(echo $shaparent2 | sed -E "s/[[:cntrl:]]\[[0-9]{1,3}m//g")
dolt merge test-branch
run dolt merge test-branch
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --theirs .
dolt commit -m "final merge"
@@ -424,7 +426,10 @@ SQL
# remove special characters (color)
shaparent2=$(echo $shaparent2 | sed -E "s/[[:cntrl:]]\[[0-9]{1,3}m//g")
dolt merge test-branch
run dolt merge test-branch
[ "$status" -eq 1 ]
echo "$output"
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --theirs .
dolt commit -m "final merge"

View File

@@ -103,7 +103,9 @@ SQL
dolt commit -m "Added column c2 longtext"
dolt checkout main
dolt merge branch1
dolt merge branch2
run dolt merge branch2
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (schema):" ]] || false
}
@test "column_tags: Merging branches that use the same tag referring to different column names fails" {
@@ -128,7 +130,9 @@ SQL
dolt commit -m "Added column c0 bigint"
dolt checkout main
dolt merge branch1
dolt merge branch2
run dolt merge branch2
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (schema):" ]] || false
}
@test "column_tags: Merging branches that both created the same column succeeds" {

View File

@@ -37,7 +37,9 @@ MODIFY COLUMN age BIGINT;
SQL
dolt commit -am "left"
dolt merge right -m "merge right"
run dolt merge right -m "merge right"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (schema):" ]] || false
run dolt conflicts cat .
[ "$status" -eq 0 ]
@@ -78,7 +80,9 @@ UPDATE t set col1 = 0 where pk = 3;
INSERT INTO t VALUES (4, 4);
SQL
dolt commit -am 'left edit'
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
# trick to disable colors
dolt conflicts cat . > output.txt
@@ -112,7 +116,9 @@ SQL
dolt sql -q "INSERT INTO t values (1, 3);"
dolt commit -am "left"
dolt merge right -m "merge right"
run dolt merge right -m "merge right"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt conflicts cat .
[[ "$output" =~ "| a" ]] || false
@@ -135,7 +141,9 @@ ALTER TABLE t ADD c INT;
INSERT INTO t VALUES (1, 3, 1);
SQL
dolt commit -am "left"
dolt merge right -m "merge left"
run dolt merge right -m "merge left"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt conflicts cat .
[[ "$output" =~ "| a" ]] || false

View File

@@ -399,7 +399,7 @@ SQL
dolt checkout -b merge-into-modified modifier
run dolt merge deleter -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
dolt merge --abort
@@ -407,7 +407,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-modified
dolt checkout -b merge-into-modified modifier
dolt merge deleter -m "merge"
run dolt merge deleter -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --theirs foo
run dolt sql -q 'select count(*) from foo'
@@ -420,7 +422,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-modified
dolt checkout -b merge-into-modified modifier
dolt merge deleter -m "merge"
run dolt merge deleter -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --ours foo
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -430,7 +434,7 @@ SQL
dolt checkout -b merge-into-deleter deleter
run dolt merge modifier -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
dolt merge --abort
@@ -438,7 +442,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-deleter
dolt checkout -b merge-into-deleter deleter
dolt merge modifier -m "merge"
run dolt merge modifier -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --ours foo
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -450,7 +456,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-deleter
dolt checkout -b merge-into-deleter deleter
dolt merge modifier -m "merge"
run dolt merge modifier -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --theirs foo
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -477,7 +485,7 @@ SQL
dolt checkout -b merge-into-modified modifier
run dolt merge deleter -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
dolt merge --abort
@@ -485,7 +493,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-modified
dolt checkout -b merge-into-modified modifier
dolt merge deleter -m "merge"
run dolt merge deleter -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--theirs', 'foo')"
run dolt sql -q 'select count(*) from foo'
@@ -498,7 +508,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-modified
dolt checkout -b merge-into-modified modifier
dolt merge deleter -m "merge"
run dolt merge deleter -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--ours', 'foo')"
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -508,7 +520,7 @@ SQL
dolt checkout -b merge-into-deleter deleter
run dolt merge modifier -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
dolt merge --abort
@@ -516,7 +528,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-deleter
dolt checkout -b merge-into-deleter deleter
dolt merge modifier -m "merge"
run dolt merge modifier -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--ours', 'foo')"
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -528,7 +542,9 @@ SQL
dolt checkout main
dolt branch -d -f merge-into-deleter
dolt checkout -b merge-into-deleter deleter
dolt merge modifier -m "merge"
run dolt merge modifier -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--theirs', 'foo')"
run dolt sql -q 'select count(*) from foo'
[ "$status" -eq 0 ]
@@ -586,7 +602,9 @@ SQL
dolt add .
dolt commit -m "inserted 0,1"
dolt checkout main
dolt merge branch1 -m "merge"
run dolt merge branch1 -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --ours test
run dolt conflicts cat test
@@ -626,7 +644,9 @@ SQL
dolt add .
dolt commit -m "inserted 0,1"
dolt checkout main
dolt merge branch1 -m "merge"
run dolt merge branch1 -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--ours', 'test')"
[ $status -eq 0 ]

View File

@@ -154,7 +154,7 @@ SQL
dolt commit -m "changed pk=0 all cells to 11"
dolt checkout main
run dolt merge change-cell -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt status
[[ "$output" =~ "You have unmerged tables." ]] || false

View File

@@ -89,7 +89,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --ours .
@@ -108,7 +108,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --ours t
@@ -127,7 +127,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --theirs .
@@ -146,7 +146,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --theirs t
@@ -165,7 +165,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --ours .
@@ -184,7 +184,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --ours t
@@ -203,7 +203,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --theirs .
@@ -222,7 +222,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --theirs t

View File

@@ -28,7 +28,7 @@ SQL
dolt checkout main
run dolt merge other
log_status_eq "0"
log_status_eq "1"
[[ "$output" =~ "Fix constraint violations" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -58,7 +58,7 @@ SQL
dolt commit -m "this works"
run dolt merge other
log_status_eq "0"
[[ "$output" =~ "up to date" ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
}
@test "constraint-violations: dolt_force_transaction_commit along with dolt_allow_commit_conflicts ignores constraint violations" {
@@ -111,7 +111,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -158,7 +160,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -212,7 +216,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -265,7 +271,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -321,7 +329,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -372,7 +382,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -421,7 +433,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -468,7 +482,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -521,7 +537,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -574,7 +592,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -630,7 +650,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -681,7 +703,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -730,7 +754,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -777,7 +803,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -830,7 +858,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -883,7 +913,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -939,7 +971,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -990,7 +1024,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1134,7 +1170,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1184,7 +1222,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1238,7 +1278,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1294,7 +1336,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1351,7 +1395,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1403,7 +1449,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1455,7 +1503,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1505,7 +1555,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1559,7 +1611,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1615,7 +1669,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1672,7 +1728,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1724,7 +1782,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1776,7 +1836,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1826,7 +1888,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1880,7 +1944,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1936,7 +2002,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -1993,7 +2061,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2045,7 +2115,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2096,7 +2168,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2145,7 +2219,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2194,7 +2270,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2242,7 +2320,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2290,7 +2370,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2338,7 +2420,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2390,7 +2474,9 @@ SQL
dolt add -A
dolt commit --force -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2441,7 +2527,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2501,7 +2589,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2561,7 +2651,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2622,7 +2714,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2779,7 +2873,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2816,7 +2912,9 @@ SQL
dolt add -A
dolt commit -m "OC1"
dolt checkout main
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
log_status_eq "0"
@@ -2857,7 +2955,7 @@ CALL DOLT_COMMIT('-am', 'add unique key constraint');
CALL DOLT_CHECKOUT('main');
SQL
run dolt merge right
log_status_eq 0
log_status_eq 1
[[ $output =~ "CONSTRAINT VIOLATION (content): Merge created constraint violation in t" ]] || false
[[ $output =~ "Automatic merge failed; 1 table(s) are unmerged." ]] || false
}

View File

@@ -3,24 +3,24 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/{rem1,repo1}
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt init
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TMPDIRS/repo2
cd $TESTDIRS/repo2
dolt branch feature
dolt remote add test-remote file://../rem1
# table and commits only present on repo1, rem1 at start
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
@@ -28,13 +28,12 @@ setup() {
dolt commit -am "Second commit"
dolt branch feature
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
rm -rf $TESTDIRS
}
@test "fetch: basic fetch" {

View File

@@ -1121,7 +1121,9 @@ SQL
dolt add -A
dolt commit --force -m "updated parent"
dolt checkout main
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
[ "$status" -eq "0" ]
[[ "$output" =~ "table,num_violations" ]] || false
@@ -1197,7 +1199,9 @@ SQL
dolt add -A
dolt commit --force -m "updated child"
dolt checkout main
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
[ "$status" -eq "0" ]
[[ "$output" =~ "table,num_violations" ]] || false
@@ -1276,7 +1280,9 @@ SQL
dolt add -A
dolt commit --force -m "updated both"
dolt checkout main
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
[ "$status" -eq "0" ]
[[ "$output" =~ "table,num_violations" ]] || false
@@ -1306,7 +1312,9 @@ SQL
dolt add -A
dolt commit -m "added 2s"
dolt checkout main
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt conflicts resolve --theirs parent
[ "$status" -eq "1" ]
[[ "$output" =~ "violation" ]] || false
@@ -1338,7 +1346,9 @@ SQL
dolt add -A
dolt commit -m "added 2s"
dolt checkout main
dolt merge other -m "merge other"
run dolt merge other -m "merge other"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt sql <<SQL
set @@dolt_allow_commit_conflicts = 1;
call dolt_conflicts_resolve('--theirs', 'parent');

View File

@@ -195,7 +195,9 @@ setup_merge_with_cv() {
@test "garbage_collection: leave conflicts" {
setup_merge
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt sql -r csv -q "select base_pk, base_c0, our_pk, our_c0, their_pk, their_c0 from dolt_conflicts_test;"
[ $status -eq 0 ]
@@ -214,7 +216,9 @@ setup_merge_with_cv() {
@test "garbage_collection: leave constraint violations" {
setup_merge_with_cv
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -r csv -q "select pk, fk from dolt_constraint_violations_child;"
[ $status -eq 0 ]
@@ -229,7 +233,9 @@ setup_merge_with_cv() {
@test "garbage_collection: leave merge commit" {
setup_merge
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt gc
@@ -246,7 +252,9 @@ setup_merge_with_cv() {
@test "garbage_collection: leave merge commit with stored procedure" {
setup_merge
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt gc
@@ -267,7 +275,9 @@ setup_merge_with_cv() {
# make a dirty working set with table quiz
dolt sql -q "INSERT INTO quiz VALUES (9,99)"
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt gc
run dolt merge --abort
[ "$status" -eq 0 ]

View File

@@ -21,7 +21,6 @@ SKIP_SERVER_TESTS=$(cat <<-EOM
~sql-local-remote.bats~
~1pk5col-strings.bats~
~sql-tags.bats~
~sql-pull.bats~
~empty-repo.bats~
~verify-constraints.bats~
~db-revision-specifiers.bats~

View File

@@ -2196,7 +2196,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt index cat onepk idx_v1 -r=csv
[ "$status" -eq "0" ]
[[ "$output" =~ "v1,pk1" ]] || false
@@ -2232,7 +2234,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --ours onepk
run dolt index cat onepk idx_v1 -r=csv
[ "$status" -eq "0" ]
@@ -2259,7 +2263,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--ours', 'onepk')"
run dolt index cat onepk idx_v1 -r=csv
[ "$status" -eq "0" ]
@@ -2287,7 +2293,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt conflicts resolve --theirs onepk
run dolt index cat onepk idx_v1 -r=csv
[ "$status" -eq "0" ]
@@ -2314,7 +2322,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
dolt sql -q "call dolt_conflicts_resolve('--theirs', 'onepk')"
run dolt index cat onepk idx_v1 -r=csv
[ "$status" -eq "0" ]
@@ -2342,7 +2352,9 @@ SQL
dolt add -A
dolt commit -m "other changes"
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content):" ]] || false
run dolt sql <<SQL
SET dolt_allow_commit_conflicts = on;
DELETE from dolt_conflicts_onepk where our_pk1 = 4;
@@ -2379,7 +2391,9 @@ SQL
dolt checkout main
dolt merge other -m "merge"
run dolt merge other -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION (content):" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations" -r=csv
[ "$status" -eq "0" ]
[[ "$output" =~ "table,num_violations" ]] || false

View File

@@ -163,7 +163,7 @@ SQL
dolt commit -am "made changes on branch another"
run dolt merge other -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --ours js
[ "$status" -eq 0 ]
@@ -213,7 +213,7 @@ SQL
dolt commit -am "made changes on branch another"
run dolt merge other -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--ours', 'js')"
[ "$status" -eq 0 ]

View File

@@ -159,7 +159,7 @@ SQL
dolt commit -am "made changes on branch another"
run dolt merge other -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --ours js
[ "$status" -eq 0 ]
@@ -209,7 +209,7 @@ SQL
dolt commit -am "made changes on branch another"
run dolt merge other -m "merge"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--ours', 'js')"
[ "$status" -eq 0 ]

View File

@@ -305,7 +305,7 @@ SQL
dolt commit -am "inserted on other"
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
run dolt sql -q "SELECT * FROM keyless WHERE c0 > 6 ORDER BY c0;" -r csv
[ $status -eq 0 ]
[[ "${lines[1]}" = "7,7" ]] || false
@@ -414,7 +414,7 @@ SQL
dolt commit -am "deleted four rows on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --ours dupe
@@ -439,7 +439,7 @@ SQL
dolt commit -am "deleted four rows on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--ours', 'dupe')"
@@ -487,7 +487,7 @@ SQL
dolt commit -am "updated four rows on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --theirs dupe
@@ -512,7 +512,7 @@ SQL
dolt commit -am "updated four rows on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--theirs', 'dupe')"
@@ -676,7 +676,7 @@ CSV
dolt commit -am "updated on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --ours keyless
@@ -723,7 +723,7 @@ CSV
dolt commit -am "inserted on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
run dolt sql -q "SELECT count(*) FROM keyless WHERE c0 > 6;" -r csv
[ $status -eq 0 ]
[[ "${lines[1]}" = "3" ]] || false
@@ -770,7 +770,7 @@ SQL
dolt commit -am "inserted on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --theirs keyless
@@ -798,7 +798,7 @@ SQL
dolt commit -am "inserted on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--theirs', 'keyless')"
@@ -838,7 +838,7 @@ SQL
dolt commit -am "inserted on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --ours keyless
@@ -863,7 +863,7 @@ SQL
dolt commit -am "inserted on other"
run dolt merge main -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--ours', 'keyless')"
@@ -921,7 +921,7 @@ SQL
dolt commit -am "inserted twos on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt conflicts resolve --theirs keyless
@@ -947,7 +947,7 @@ SQL
dolt commit -am "inserted twos on left"
run dolt merge right -m "merge"
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -q "call dolt_conflicts_resolve('--theirs', 'keyless')"

View File

@@ -144,7 +144,9 @@ SQL
# dirty the working set with changes to test2
dolt sql -q "INSERT INTO test2 VALUES (9,9,9);"
dolt merge other --no-commit
run dolt merge other --no-commit
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
dolt merge --abort
run dolt sql -q "SELECT * from dolt_merge_status"
@@ -257,7 +259,8 @@ SQL
dolt commit -m "add pk 0 = 2,2 to test1"
run dolt merge merge_branch -m "merge_branch"
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
[[ "$output" =~ "test1" ]] || false
dolt add test1
@@ -286,7 +289,8 @@ SQL
dolt commit -m "add pk 0 = 2,2 to test1"
run dolt merge merge_branch --no-commit
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
[[ "$output" =~ "test1" ]] || false
run dolt commit -m 'create a merge commit'
@@ -533,7 +537,8 @@ SQL
dolt commit -am "added row"
run dolt merge other
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -q "select * from dolt_constraint_violations" -r=csv
[[ "$output" =~ "test,2" ]] || false
@@ -773,10 +778,13 @@ SQL
dolt commit -am "non-fk insert"
dolt checkout main
dolt merge right
run dolt merge right
log_status_eq 1
[[ "$output" =~ "Automatic merge failed" ]] || false
dolt commit -afm "commit constraint violations"
dolt merge other --no-commit
run dolt merge other --no-commit
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -r csv -q "SELECT violation_type, pk, parent_fk from dolt_constraint_violations_child;";
[[ "${lines[1]}" = "foreign key,1,1" ]] || false
@@ -827,7 +835,8 @@ SQL
dolt commit -afm "committing merge conflicts"
# merge should be allowed and previous conflicts and violations should be retained
dolt merge other2 --no-commit
run dolt merge other2 --no-commit
[[ "$output" =~ "Automatic merge failed" ]] || false
run dolt sql -r csv -q "SELECT * FROM parent;"
[[ "${lines[1]}" = "1,2" ]] || false
[[ "${lines[2]}" = "3,1" ]] || false
@@ -869,7 +878,7 @@ SQL
# Create a conflicted state by merging other into main
run dolt merge other
log_status_eq 0
log_status_eq 1
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -r csv -q "SELECT * FROM parent;"
@@ -971,7 +980,7 @@ SQL
dolt checkout main
run dolt merge other --no-commit --commit
log_status_eq 1
[[ "$output" =~ "cannot define both 'commit' and 'no-commit' flags at the same time" ]] || false
[[ "$output" =~ "Flags '--commit' and '--no-commit' cannot be used together" ]] || false
run dolt merge other --no-commit
log_status_eq 0

455
integration-tests/bats/pull.bats Executable file
View File

@@ -0,0 +1,455 @@
#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TESTDIRS/repo1
dolt init
dolt branch feature
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TESTDIRS/repo2
dolt log
dolt branch feature
dolt remote add test-remote file://../rem1
# table and commits only present on repo1, rem1 at start
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
dolt sql -q "insert into t1 values (0,0)"
dolt commit -am "Second commit"
dolt push origin main
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TESTDIRS
}
@test "pull: pull main" {
cd repo2
dolt pull origin
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
}
@test "pull: pull custom remote" {
cd repo2
dolt pull test-remote
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
}
@test "pull: pull default origin" {
cd repo2
dolt remote remove test-remote
dolt pull
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
}
@test "pull: pull default custom remote" {
cd repo2
dolt remote remove origin
dolt pull
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
}
@test "pull: pull up to date does not error" {
cd repo2
dolt pull origin
run dolt pull origin
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date" ]] || false
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
}
@test "pull: pull unknown remote fails" {
cd repo2
run dolt pull unknown
[ "$status" -eq 1 ]
[[ "$output" =~ "unknown remote" ]] || false
[[ ! "$output" =~ "panic" ]] || false
}
@test "pull: pull unknown feature branch fails" {
cd repo2
dolt checkout feature
run dolt pull origin
[ "$status" -eq 1 ]
[[ "$output" =~ "You asked to pull from the remote 'origin', but did not specify a branch" ]] || false
[[ ! "$output" =~ "panic" ]] || false
}
@test "pull: pull feature branch" {
cd repo1
dolt checkout feature
dolt push --set-upstream origin feature
cd ../repo2
dolt checkout feature
dolt push --set-upstream origin feature
cd ../repo1
dolt merge main
dolt push
cd ../repo2
dolt pull origin
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
}
@test "pull: checkout after fetch a new feature branch" {
cd repo1
dolt checkout -b feature2
dolt sql -q "create table t2 (i int primary key);"
dolt sql -q "call dolt_add('.');"
dolt sql -q "call dolt_commit('-am', 'create t2')"
dolt push --set-upstream origin feature2
cd ../repo2
dolt fetch origin feature2
dolt checkout feature2
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
[[ "$output" =~ "t2" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
[[ "$output" =~ "create t2" ]] || false
}
@test "pull: pull force" {
cd repo1
# disable foreign key checks to create merge conflicts
dolt sql <<SQL
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE colors (
id INT NOT NULL,
color VARCHAR(32) NOT NULL,
PRIMARY KEY (id),
INDEX color_index(color)
);
CREATE TABLE objects (
id INT NOT NULL,
name VARCHAR(64) NOT NULL,
color VARCHAR(32)
);
SQL
dolt commit -A -m "Commit1"
dolt push origin main
cd ../repo2
dolt pull
dolt sql -q "alter table objects add constraint color FOREIGN KEY (color) REFERENCES colors(color)"
dolt commit -A -m "Commit2"
cd ../repo1
dolt sql -q "INSERT INTO objects (id,name,color) VALUES (1,'truck','red'),(2,'ball','green'),(3,'shoe','blue')"
dolt commit -A -m "Commit3"
dolt push origin main
cd ../repo2
run dolt pull
[ "$status" -eq 1 ]
[[ "$output" =~ "CONSTRAINT VIOLATION" ]] || false
dolt merge --abort
run dolt pull --force
[ "$status" -eq 0 ]
run dolt sql -q "select * from objects"
[ "$status" -eq 0 ]
[[ "$output" =~ "truck" ]] || false
[[ "$output" =~ "ball" ]] || false
[[ "$output" =~ "shoe" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "First commit" ]] || false
[[ "$output" =~ "Second commit" ]] || false
[[ "$output" =~ "Commit1" ]] || false
[[ "$output" =~ "Commit3" ]] || false
}
@test "pull: pull squash" {
cd repo2
dolt sql -q "create table t2 (i int primary key);"
dolt commit -Am "commit 1"
dolt pull --squash origin
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
[[ "$output" =~ "t2" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "Merge branch" ]] || false
[[ ! "$output" =~ "Second commit" ]] || false
[[ ! "$output" =~ "First commit" ]] || false
}
@test "pull: pull --noff flag" {
cd repo2
dolt pull --no-ff origin
dolt status
run dolt log -n 1
[ "$status" -eq 0 ]
[[ "$output" =~ "Merge branch 'main'" ]] || false
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
}
@test "pull: pull dirty working set fails" {
cd repo2
dolt pull
cd ../repo1
dolt sql -q "insert into t1 values (3, 3)"
dolt commit -am "dirty commit"
dolt push origin main
cd ../repo2
dolt sql -q "insert into t1 values (2, 2)"
run dolt pull origin
[ "$status" -eq 1 ]
[[ "$output" =~ "cannot merge with uncommitted changes" ]] || false
}
@test "pull: pull tag" {
cd repo1
dolt tag v1
dolt push origin v1
dolt tag
cd ../repo2
dolt pull origin
run dolt tag
[ "$status" -eq 0 ]
[[ "$output" =~ "v1" ]] || false
}
@test "pull: pull tags only for resolved commits" {
cd repo1
dolt tag v1 head
dolt tag v2 head^
dolt push origin v1
dolt push origin v2
dolt checkout feature
dolt sql -q "create table t2 (a int)"
dolt add .
dolt commit -am "feature commit"
dolt tag v3
dolt push origin v3
cd ../repo2
dolt pull origin
run dolt tag
[ "$status" -eq 0 ]
[[ "$output" =~ "v1" ]] || false
[[ "$output" =~ "v2" ]] || false
[[ ! "$output" =~ "v3" ]] || false
}
@test "pull: pull with remote and remote ref" {
cd repo1
dolt checkout feature
dolt checkout -b newbranch
run dolt sql -q "show tables"
[ "$status" -eq 0 ]
[[ ! "$output" =~ "t1" ]] || false
# Specifying a non-existent remote branch returns an error
run dolt pull origin doesnotexist
[ "$status" -eq 1 ]
[[ "$output" =~ 'branch "doesnotexist" not found on remote' ]] || false
# Explicitly specifying the remote and branch will merge in that branch
run dolt pull origin main
[ "$status" -eq 0 ]
run dolt sql -q "show tables"
[ "$status" -eq 0 ]
[[ "$output" =~ "t1" ]] || false
run dolt status
[ "$status" -eq 0 ]
[[ "$output" =~ "working tree clean" ]] || false
# Make a conflicting working set change and test that pull complains
dolt reset --hard HEAD^1
dolt sql -q "insert into t1 values (0, 100);"
run dolt pull origin main
[ "$status" -eq 1 ]
[[ "$output" =~ 'cannot merge with uncommitted changes' ]] || false
# Commit changes and test that a merge conflict fails the pull
dolt commit -am "adding new t1 table"
run dolt pull origin main
[ "$status" -eq 1 ]
[[ "$output" =~ "Auto-merging t1" ]] || false
[[ "$output" =~ "CONFLICT (content): Merge conflict in t1" ]] || false
[[ "$output" =~ "Automatic merge failed; 1 table(s) are unmerged." ]] || false
[[ "$output" =~ "Use 'dolt conflicts' to investigate and resolve conflicts." ]] || false
run dolt show head
[ "$status" -eq 0 ]
[[ "$output" =~ "adding new t1 table" ]] || false
}
@test "pull: pull also fetches, but does not merge other branches" {
cd repo1
dolt checkout -b other
dolt push --set-upstream origin other
dolt checkout feature
dolt push origin feature
cd ../repo2
dolt fetch
# this checkout will set upstream because 'other' branch is a new branch that matches one of remote tracking branch
dolt checkout other
# this checkout will not set upstream because this 'feature' branch existed before matching remote tracking branch was created
dolt checkout feature
dolt push --set-upstream origin feature
cd ../repo1
dolt merge main
dolt push origin feature
dolt checkout other
dolt commit --allow-empty -m "new commit on other"
dolt push
cd ../repo2
dolt pull
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
dolt checkout other
run dolt log --oneline -n 1
[ "$status" -eq 0 ]
[[ ! "$output" =~ "new commit on other" ]] || false
run dolt status
[ "$status" -eq 0 ]
[[ "$output" =~ "behind 'origin/other' by 1 commit" ]] || false
}
@test "pull: pull commits successful merge on current branch" {
cd repo1
dolt checkout -b other
dolt push --set-upstream origin other
cd ../repo2
dolt fetch
# this checkout will set upstream because 'other' branch is a new branch that matches one of remote tracking branch
dolt checkout other
cd ../repo1
dolt sql -q "insert into t1 values (1, 2)"
dolt commit -am "add (1,2) to t1"
dolt push
cd ../repo2
run dolt sql -q "select * from t1" -r csv
[ "$status" -eq 0 ]
[[ ! "$output" =~ "1,2" ]] || false
dolt sql -q "insert into t1 values (2, 3)"
dolt commit -am "add (2,3) to t1"
run dolt pull
[ "$status" -eq 0 ]
run dolt log --oneline -n 1
[ "$status" -eq 0 ]
[[ "$output" =~ "Merge branch 'other' of" ]] || false
[[ ! "$output" =~ "add (1,2) to t1" ]] || false
[[ ! "$output" =~ "add (2,3) to t1" ]] || false
}
@test "pull: --no-ff and --no-commit" {
cd repo2
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 1 ]
run dolt pull --no-ff --no-commit origin
[ "$status" -eq 0 ]
[[ "$output" =~ "Automatic merge went well; stopped before committing as requested" ]] || false
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "t1" ]] || false
dolt commit -m "merge from origin"
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "merge from origin" ]] || false
}

View File

@@ -4,36 +4,35 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/{rem1,repo1}
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt init
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TMPDIRS/repo2
cd $TESTDIRS/repo2
dolt log
dolt remote add test-remote file://../rem1
# table and comits only present on repo1, rem1 at start
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
dolt sql -q "insert into t1 values (0,0)"
dolt commit -am "Second commit"
cd $TMPDIRS
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
rm -rf $TESTDIRS
}
@test "push: push origin" {

View File

@@ -109,7 +109,7 @@ teardown() {
dolt checkout main
dolt merge edit_a -m "merge edit_a"
run dolt merge edit_b -m "merge edit_b"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "Merge conflict in dolt_query_catalog" ]] || false
run dolt conflicts cat .

View File

@@ -69,7 +69,7 @@ teardown() {
dolt clone file://./remote repo2
cd repo2
dolt pull
dolt pull
dolt commit --allow-empty -m "a commit for main from repo2"
@@ -404,7 +404,7 @@ SQL
dolt sql -q "create table t1 (pk int primary key);"
run dolt pull test-remote test-branch
[ "$status" -eq 1 ]
[[ "$output" =~ 'local changes to the following tables would be overwritten by merge' ]] || false
[[ "$output" =~ 'cannot merge with uncommitted changes' ]] || false
# Commit changes and test that a merge conflict fails the pull
dolt add .
@@ -933,7 +933,7 @@ SQL
[[ ! "$output" =~ "test commit" ]] || false
run dolt merge origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Already up to date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
run dolt fetch
[ "$status" -eq 0 ]
run dolt merge origin/main
@@ -967,7 +967,7 @@ SQL
cd "dolt-repo-clones/test-repo"
run dolt merge remotes/origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Already up to date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
run dolt fetch origin main
[ "$status" -eq 0 ]
run dolt merge remotes/origin/main
@@ -1153,7 +1153,7 @@ SQL
dolt add test
dolt commit -m "conflicting row"
run dolt pull origin
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
dolt conflicts resolve test --ours
dolt add test
@@ -1234,9 +1234,7 @@ SQL
dolt sql -q "insert into test values (0, 1, 1, 1, 1, 1)"
run dolt pull origin
[ "$status" -ne 0 ]
[[ "$output" =~ "error: Your local changes to the following tables would be overwritten by merge:" ]] || false
[[ "$output" =~ "test" ]] || false
[[ "$output" =~ "Please commit your changes before you merge." ]] || false
[[ "$output" =~ "cannot merge with uncommitted changes" ]] || false
}
@test "remotes: force push to main" {
@@ -1351,7 +1349,7 @@ SQL
[ "$status" -eq 0 ]
}
@test "remotes: validate that a config isn't needed for a pull." {
@test "remotes: validate that a config is needed for a pull." {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote main
dolt fetch test-remote
@@ -1373,17 +1371,23 @@ SQL
cd "dolt-repo-clones/test-repo"
dolt config --global --unset user.name
dolt config --global --unset user.email
run dolt pull
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "Could not determine name and/or email." ]] || false
dolt config --global --add user.name mysql-test-runner
dolt config --global --add user.email mysql-test-runner@liquidata.co
dolt pull
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
# test pull with workspace up to date
dolt config --global --unset user.name
dolt config --global --unset user.email
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[ "$status" -eq 1 ]
[[ "$output" =~ "Could not determine name and/or email." ]] || false
# turn back on the configs and make a change in the remote
dolt config --global --add user.name mysql-test-runner
@@ -1402,7 +1406,7 @@ SQL
run dolt pull --no-ff
[ "$status" -eq 1 ]
[[ "$output" =~ "Aborting commit due to empty committer name. Is your config set?" ]] || false
[[ "$output" =~ "Could not determine name and/or email." ]] || false
# Now do a two sided merge
dolt config --global --add user.name mysql-test-runner
@@ -1422,7 +1426,7 @@ SQL
run dolt pull
[ "$status" -eq 1 ]
[[ "$output" =~ "Aborting commit due to empty committer name. Is your config set?" ]] || false
[[ "$output" =~ "Could not determine name and/or email." ]] || false
}
create_main_remote_branch() {
@@ -2047,7 +2051,8 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
echo "$output"
[[ "$output" =~ "Everything up-to-date" ]] || false
}
@test "remotes: call dolt_checkout track flag sets upstream" {
@@ -2085,7 +2090,7 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
}
@test "remotes: call dolt_checkout with --track and no arg returns error" {
@@ -2125,7 +2130,7 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
dolt checkout main
dolt branch -D newbranch
@@ -2138,10 +2143,10 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
}
@test "remotes: dolt sql -q 'call dolt_checkout("-b", "newbranch", "--track", "origin/feature")'' checks out new local branch 'newbranch' with upstream set" {
@test "remotes: call dolt_checkout('-b', 'newbranch', '--track', 'origin/feature') checks out new local branch 'newbranch' with upstream set" {
mkdir remote
mkdir repo1
@@ -2167,7 +2172,7 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
dolt checkout main
dolt branch -D newbranch
@@ -2182,7 +2187,7 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
}
@test "remotes: dolt branch track flag sets upstream" {
@@ -2217,7 +2222,7 @@ SQL
dolt checkout other
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
# NOTE: this command fails with git, requiring `--track=direct`, when both branch name and starting point name are defined, but Dolt allows both formats.
run dolt branch feature --track direct origin/other
@@ -2281,7 +2286,7 @@ SQL
run dolt pull
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date." ]] || false
[[ "$output" =~ "Everything up-to-date" ]] || false
# NOTE: this command fails with git, requiring `--track=direct`, when both branch name and starting point name are defined, but Dolt allows both formats.
dolt sql -q "CALL DOLT_BRANCH('feature','--track','direct','origin/other');"

View File

@@ -42,7 +42,9 @@ setup_schema_conflict() {
@test "schema-conflicts: cli merge, query schema conflicts" {
setup_schema_conflict
dolt merge other
run dolt merge other
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (schema)" ]] || false
run dolt sql -q "select our_schema from dolt_schema_conflicts" -r csv
[ "$status" -eq 0 ]

View File

@@ -89,7 +89,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt sql -q "CALL dolt_conflicts_resolve('--ours', 't')"
@@ -108,7 +108,7 @@ teardown() {
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt sql -q "CALL dolt_conflicts_resolve('--theirs', 't')"
@@ -127,7 +127,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt sql -q "CALL dolt_conflicts_resolve('--ours', 't')"
@@ -146,7 +146,7 @@ teardown() {
[[ $output =~ "other" ]] || false
run dolt merge main
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt sql -q "CALL dolt_conflicts_resolve('--theirs', 't')"

View File

@@ -46,7 +46,9 @@ teardown() {
dolt add .
dolt commit -m "changed feature_branch"
dolt checkout main
dolt merge feature_branch -m "merge"
run dolt merge feature_branch -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
EXPECTED=$( echo -e "table,num_conflicts\none_pk,1\ntwo_pk,1")
run dolt sql -r csv -q "SELECT * FROM dolt_conflicts ORDER BY \`table\`"
@@ -108,7 +110,9 @@ SQL
dolt add .
dolt commit -m "changed feature_branch"
dolt checkout main
dolt merge feature_branch -m "merge"
run dolt merge feature_branch -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
EXPECTED=$( echo -e "table,num_conflicts\none_pk,1\ntwo_pk,1")
run dolt sql -r csv -q "SELECT * FROM dolt_conflicts ORDER BY \`table\`"
@@ -166,7 +170,9 @@ SQL
dolt add .
dolt commit -m "changed feature_branch"
dolt checkout main
dolt merge feature_branch -m "merge"
run dolt merge feature_branch -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
EXPECTED=$( echo -e "table,num_conflicts\none_pk,1\ntwo_pk,1")
run dolt sql -r csv -q "SELECT * FROM dolt_conflicts ORDER BY \`table\`"
@@ -229,7 +235,9 @@ SQL
dolt add .
dolt commit -m "changed feature_branch"
dolt checkout main
dolt merge feature_branch -m "merge"
run dolt merge feature_branch -m "merge"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content)" ]] || false
EXPECTED=$( echo -e "table,num_conflicts\none_pk,5")
run dolt sql -r csv -q "SELECT * FROM dolt_conflicts"

View File

@@ -3,24 +3,24 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/{rem1,repo1}
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt init
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TMPDIRS/repo2
cd $TESTDIRS/repo2
dolt branch feature
dolt remote add test-remote file://../rem1
# table and commits only present on repo1, rem1 at start
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
@@ -28,13 +28,12 @@ setup() {
dolt commit -am "Second commit"
dolt branch feature
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
rm -rf $TESTDIRS
}
@test "sql-fetch: dolt_fetch default" {

View File

@@ -523,7 +523,9 @@ MODIFY COLUMN age BIGINT;
SQL
dolt commit -am "left"
dolt merge right -m "merge right"
run dolt merge right -m "merge right"
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (schema)" ]] || false
run dolt conflicts cat .
[ "$status" -eq 0 ]
@@ -739,7 +741,7 @@ SQL
[ $status -eq 0 ]
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
# start server
@@ -768,7 +770,7 @@ SQL
[[ $output =~ "main" ]] || false
run dolt merge other
[ $status -eq 0 ]
[ $status -eq 1 ]
[[ $output =~ "Automatic merge failed" ]] || false
run dolt conflicts resolve --ours .
@@ -1182,3 +1184,34 @@ SQL
[ $status -eq 0 ]
[[ "$output" =~ "cm2" ]] || false
}
@test "sql-local-remote: verify dolt pull behavior" {
mkdir remote
cd altDB
dolt remote add origin file://../remote
dolt commit --allow-empty -m "cm1"
dolt push origin main
cd ..
dolt clone file://./remote repo
cd altDB
dolt commit --allow-empty -m "cm2"
dolt push origin main
cd ../repo
dolt pull
run dolt log
[ $status -eq 0 ]
[[ "$output" =~ "cm2" ]] || false
cd ../altDB
dolt commit --allow-empty -m "cm3"
dolt push origin main
cd ../repo
start_sql_server repo
dolt pull origin main
run dolt log
[ $status -eq 0 ]
[[ "$output" =~ "cm3" ]] || false
}

View File

@@ -4,39 +4,38 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/{rem1,repo1}
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt init
dolt branch feature
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TMPDIRS/repo2
cd $TESTDIRS/repo2
dolt log
dolt branch feature
dolt remote add test-remote file://../rem1
# table and commits only present on repo1, rem1 at start
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
dolt sql -q "insert into t1 values (0,0)"
dolt commit -am "Second commit"
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
rm -rf $TESTDIRS
}
@test "sql-pull: dolt_pull main" {
@@ -160,44 +159,68 @@ teardown() {
}
@test "sql-pull: dolt_pull force" {
skip "todo: support dolt pull --force (cli too)"
cd repo2
dolt sql -q "create table t2 (a int)"
dolt commit -am "2.0 commit"
cd repo1
# disable foreign key checks to create merge conflicts
dolt sql <<SQL
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE colors (
id INT NOT NULL,
color VARCHAR(32) NOT NULL,
PRIMARY KEY (id),
INDEX color_index(color)
);
CREATE TABLE objects (
id INT NOT NULL,
name VARCHAR(64) NOT NULL,
color VARCHAR(32)
);
SQL
dolt commit -A -m "Commit1"
dolt push origin main
cd ../repo2
dolt pull
dolt sql -q "alter table objects add constraint color FOREIGN KEY (color) REFERENCES colors(color)"
dolt commit -A -m "Commit2"
cd ../repo1
dolt sql -q "create table t2 (a int primary key)"
dolt sql -q "create table t3 (a int primary key)"
dolt commit -am "2.1 commit"
dolt push -f origin main
dolt sql -q "INSERT INTO objects (id,name,color) VALUES (1,'truck','red'),(2,'ball','green'),(3,'shoe','blue')"
dolt commit -A -m "Commit3"
dolt push origin main
cd ../repo2
run dolt sql -q "CALL dolt_pull('origin')"
run dolt sql -q "call dolt_pull()"
[ "$status" -eq 1 ]
[[ ! "$output" =~ "panic" ]] || false
[[ "$output" =~ "fetch failed; dataset head is not ancestor of commit" ]] || false
[[ "$output" =~ "Constraint violations" ]] || false
dolt sql -q "CALL dolt_pull('-f', 'origin')"
run dolt log -n 1
run dolt sql -q "call dolt_pull('--force')"
[ "$status" -eq 0 ]
[[ "$output" =~ "2.1 commit" ]] || false
run dolt sql -q "show tables" -r csv
[ "${#lines[@]}" -eq 4 ]
[[ "$output" =~ "t3" ]] || false
run dolt sql -q "select * from objects"
[ "$status" -eq 0 ]
[[ "$output" =~ "truck" ]] || false
[[ "$output" =~ "ball" ]] || false
[[ "$output" =~ "shoe" ]] || false
}
@test "sql-pull: CALL dolt_pull squash" {
skip "todo: support dolt pull --squash (cli too)"
cd repo2
dolt sql -q "create table t2 (i int primary key);"
dolt commit -Am "commit 1"
dolt sql -q "CALL dolt_pull('--squash', 'origin')"
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[ "${#lines[@]}" -eq 3 ]
[[ "$output" =~ "Table" ]] || false
[[ "$output" =~ "t1" ]] || false
[[ "$output" =~ "t2" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "Merge branch" ]] || false
[[ ! "$output" =~ "Second commit" ]] || false
[[ ! "$output" =~ "First commit" ]] || false
}
@test "sql-pull: dolt_pull --noff flag" {
@@ -423,3 +446,22 @@ teardown() {
[[ ! "$output" =~ "add (1,2) to t1" ]] || false
[[ ! "$output" =~ "add (2,3) to t1" ]] || false
}
@test "sql-pull: --no-ff and --no-commit" {
cd repo2
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 1 ]
dolt sql -q "call dolt_pull('--no-ff', '--no-commit')"
run dolt sql -q "show tables" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "t1" ]] || false
dolt commit -m "merge from origin"
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "merge from origin" ]] || false
}

View File

@@ -4,36 +4,35 @@ load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
TMPDIRS=$(pwd)/tmpdirs
mkdir -p $TMPDIRS/{rem1,repo1}
TESTDIRS=$(pwd)/testdirs
mkdir -p $TESTDIRS/{rem1,repo1}
# repo1 -> rem1 -> repo2
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt init
dolt remote add origin file://../rem1
dolt remote add test-remote file://../rem1
dolt push origin main
cd $TMPDIRS
cd $TESTDIRS
dolt clone file://rem1 repo2
cd $TMPDIRS/repo2
cd $TESTDIRS/repo2
dolt log
dolt remote add test-remote file://../rem1
# table and comits only present on repo1, rem1 at start
cd $TMPDIRS/repo1
cd $TESTDIRS/repo1
dolt sql -q "create table t1 (a int primary key, b int)"
dolt add .
dolt commit -am "First commit"
dolt sql -q "insert into t1 values (0,0)"
dolt commit -am "Second commit"
cd $TMPDIRS
cd $TESTDIRS
}
teardown() {
teardown_common
rm -rf $TMPDIRS
cd $BATS_TMPDIR
rm -rf $TESTDIRS
}
@test "sql-push: dolt_push origin" {

View File

@@ -99,7 +99,7 @@ teardown() {
dolt commit -m "changed pk=0 all cells to 11"
dolt checkout main
run dolt merge change-cell -m "merge change-cell"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT" ]] || false
run dolt sql -r csv -q "select * from dolt_status"
@@ -143,7 +143,7 @@ teardown() {
# A merge with conflicts does not change the working root.
# If the conflicts are resolved with --ours, the working root and the docs on the filesystem remain the same.
run dolt merge test-b -m "merge test-b"
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ $output =~ "CONFLICT" ]] || false
dolt status

View File

@@ -108,7 +108,7 @@ SQL
dolt sql -q "INSERT INTO t VALUES (2,2);"
dolt add -A && dolt commit -m "added values on branch main"
run dolt merge other
[ "$status" -eq 0 ]
[ "$status" -eq 1 ]
[[ "$output" =~ "CONFLICT (content): Merge conflict in t" ]] || false
run dolt status
[ "$status" -eq 0 ]

View File

@@ -193,16 +193,10 @@ EOF
}
@test "dolt merge other into $DEFAULT_BRANCH" {
run dolt version
if [[ $output =~ "__DOLT__" ]]; then
run dolt merge other
[ $status -eq 0 ]
[[ $output =~ "Merge conflict in abc" ]] || false
[[ $output =~ "Automatic merge failed" ]] || false
else
# throws a conflict
dolt merge other
fi
run dolt merge other
[ $status -eq 1 ]
[[ $output =~ "Merge conflict in abc" ]] || false
[[ $output =~ "Automatic merge failed" ]] || false
}
@test "dolt table import" {
@@ -212,4 +206,3 @@ EOF
dolt sql -q 'drop table abc2'
}