mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-06 18:59:02 -06:00
refactor root update in merge.go
This commit is contained in:
@@ -763,7 +763,6 @@ func MergeRoots(ctx context.Context, ourRoot, theirRoot, ancRoot *doltdb.RootVal
|
||||
tableEditSession := editor.CreateTableEditSession(ourRoot, editor.TableEditSessionProps{
|
||||
ForeignKeyChecksDisabled: true,
|
||||
})
|
||||
var unconflicted []string
|
||||
// need to validate merges can be done on all tables before starting the actual merges.
|
||||
for _, tblName := range tblNames {
|
||||
mergedTable, stats, err := merger.MergeTable(ctx, tblName, tableEditSession)
|
||||
@@ -775,10 +774,6 @@ func MergeRoots(ctx context.Context, ourRoot, theirRoot, ancRoot *doltdb.RootVal
|
||||
if mergedTable != nil {
|
||||
tblToStats[tblName] = stats
|
||||
|
||||
if stats.Conflicts == 0 {
|
||||
unconflicted = append(unconflicted, tblName)
|
||||
}
|
||||
|
||||
err = tableEditSession.UpdateRoot(ctx, func(ctx context.Context, root *doltdb.RootValue) (*doltdb.RootValue, error) {
|
||||
return root.PutTable(ctx, tblName, mergedTable)
|
||||
})
|
||||
@@ -813,10 +808,14 @@ func MergeRoots(ctx context.Context, ourRoot, theirRoot, ancRoot *doltdb.RootVal
|
||||
if len(conflicts) > 0 {
|
||||
return nil, fmt.Errorf("foreign key conflicts")
|
||||
}
|
||||
return root.PutForeignKeyCollection(ctx, mergedFKColl)
|
||||
})
|
||||
|
||||
newRoot, err = newRoot.UpdateSuperSchemasFromOther(ctx, unconflicted, theirRoot)
|
||||
root, err = root.PutForeignKeyCollection(ctx, mergedFKColl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return root.UpdateSuperSchemasFromOther(ctx, tblNames, theirRoot)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user