Files
dolt/go/datas/commit_options.go
cmasone-attic e954427903 Go: add heuristic merge option to db.Commit() (#2759)
This patch adds an optional MergePolicy field to CommitOptions. It's a
callback. If the caller sets it, then the commit code will look for a
common ancestor between the Dataset HEAD and the provided Commit. If
the caller-provided Commit descends from HEAD, then Commit proceeds as
normal.
If it does not, but there is a common ancestor, the code runs
merge.ThreeWay() on the values of the provided Commit, HEAD, and the
common ancestor, invoking the MergePolicy callback to resolve
conflicts. If merge succeeds, a merge Commit is created that descends
from both HEAD and the caller-provided Commit. This becomes the new
HEAD of the Dataset.

Fixes #2534
2016-10-27 11:52:46 -07:00

28 lines
890 B
Go

// Copyright 2016 Attic Labs, Inc. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package datas
import (
"github.com/attic-labs/noms/go/merge"
"github.com/attic-labs/noms/go/types"
)
// CommitOptions is used to pass options into Commit.
type CommitOptions struct {
// Parents, if provided is the parent commits of the commit we are
// creating.
Parents types.Set
// Meta is a Struct that describes arbitrary metadata about this Commit,
// e.g. a timestamp or descriptive text.
Meta types.Struct
// Policy will be called to attempt to merge this Commit with the current
// Head, if this is not a fast-forward. If Policy is nil, no merging will
// be attempted. Note that because Commit() retries in some cases, Policy
// might also be called multiple times with different values.
Policy merge.Policy
}