Skip to content

Commit

Permalink
Merge pull request #7412 from dolthub/nicktobey/abort
Browse files Browse the repository at this point in the history
When aborting a merge/cherry-pick, avoid resetting ignored tables.
  • Loading branch information
nicktobey authored Jan 25, 2024
2 parents 4ff2d78 + 1f12466 commit ee5ede1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
7 changes: 6 additions & 1 deletion go/libraries/doltcore/merge/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func AbortMerge(ctx *sql.Context, workingSet *doltdb.WorkingSet, roots doltdb.Ro
if err != nil {
return nil, err
}
tbls, err = doltdb.ExcludeIgnoredTables(ctx, roots, tbls)
if err != nil {
return nil, err
}

roots, err = actions.MoveTablesFromHeadToWorking(ctx, roots, tbls)
if err != nil {
Expand All @@ -191,7 +195,8 @@ func AbortMerge(ctx *sql.Context, workingSet *doltdb.WorkingSet, roots doltdb.Ro
} else {
workingSet = workingSet.WithWorkingRoot(preMergeWorkingRoot)
}
workingSet = workingSet.WithStagedRoot(workingSet.WorkingRoot())
// Unstage everything by making Staged match Head
workingSet = workingSet.WithStagedRoot(roots.Head)
workingSet = workingSet.ClearMerge()

return workingSet, nil
Expand Down
29 changes: 28 additions & 1 deletion go/libraries/doltcore/sqle/enginetest/dolt_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -5716,10 +5716,14 @@ var DoltCherryPickTests = []queries.ScriptTest{
SetUpScript: []string{
"INSERT INTO dolt_ignore VALUES ('generated_*', 1);",
"CREATE TABLE generated_foo (pk int PRIMARY KEY);",
"CREATE TABLE generated_bar (pk int PRIMARY KEY);",
"insert into generated_foo values (1);",
"insert into generated_bar values (1);",
"SET @@autocommit=1;",
"SET @@dolt_allow_commit_conflicts=1;",
"create table t (pk int primary key, v varchar(100));",
"insert into t values (1, 'one');",
"call dolt_add('--force', 'generated_bar');",
"call dolt_commit('-Am', 'create table t');",
"call dolt_checkout('-b', 'branch1');",
"update t set v=\"uno\" where pk=1;",
Expand All @@ -5743,6 +5747,16 @@ var DoltCherryPickTests = []queries.ScriptTest{
{1, "uno", 1, "modified", 1, "modified"},
},
},
{
Query: "insert into generated_foo values (2);",
},
/*
// TODO: https://github.com/dolthub/dolt/issues/7411
// see below
{
Query: "insert into generated_bar values (2);",
},
*/
{
Query: "call dolt_cherry_pick('--abort');",
Expected: []sql.Row{{"", 0, 0, 0}},
Expand All @@ -5756,9 +5770,22 @@ var DoltCherryPickTests = []queries.ScriptTest{
Expected: []sql.Row{{1, "one"}},
},
{
// An ignored table should still be present (and unstaged) after aborting the merge.
Query: "select * from dolt_status;",
Expected: []sql.Row{},
Expected: []sql.Row{{"generated_foo", false, "new table"}},
},
{
// Changes made to the table during the merge should not be reverted.
Query: "select * from generated_foo;",
Expected: []sql.Row{{1}, {2}},
},
/*{
// TODO: https://github.com/dolthub/dolt/issues/7411
// The table that was force-added should be treated like any other table
// and reverted to its state before the merge began.
Query: "select * from generated_bar;",
Expected: []sql.Row{{1}},
},*/
},
},
}
Expand Down

0 comments on commit ee5ede1

Please sign in to comment.