merge

package
v0.40.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 39 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TagCollision conflictKind = iota
	NameCollision
	ColumnCollision
	InvalidCheckCollision
	DeletedCheckCollision
)

Variables

View Source
var EmptySchConflicts = SchemaConflict{}
View Source
var ErrFailedToDetermineMergeability = errors.New("failed to determine mergeability")
View Source
var ErrFailedToDetermineUnstagedDocs = errors.New("failed to determine unstaged docs")
View Source
var ErrFailedToReadDatabase = errors.New("failed to read database")
View Source
var ErrFastForward = errors.New("fast forward")
View Source
var ErrMergeFailedToUpdateDocs = errors.New("failed to update docs to the new working root")
View Source
var ErrMergeFailedToUpdateRepoState = errors.New("unable to execute repo state update")
View Source
var ErrMergeWithDifferentPkSets = errors.New("error: cannot merge two tables with different primary key sets")
View Source
var ErrSameTblAddedTwice = errors.New("table with same name added in 2 commits can't be merged")
View Source
var ErrTableDeletedAndModified = errors.New("conflict: table with same name deleted and modified ")
View Source
var WriteBufSize = 256 * 1024

Functions

func AddConstraintViolations

func AddConstraintViolations(ctx context.Context, newRoot, baseRoot *doltdb.RootValue, tables *set.StrSet) (*doltdb.RootValue, *set.StrSet, error)

AddConstraintViolations adds all constraint violations to each table.

func AutoResolveAll

func AutoResolveAll(ctx context.Context, dEnv *env.DoltEnv, autoResolver AutoResolver) error

func AutoResolveTables

func AutoResolveTables(ctx context.Context, dEnv *env.DoltEnv, autoResolver AutoResolver, tbls []string) error

func ExecNoFFMerge

func ExecNoFFMerge(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)

func ExecuteFFMerge

func ExecuteFFMerge(
	ctx context.Context,
	dEnv *env.DoltEnv,
	spec *MergeSpec,
) error

func ExecuteMerge

func ExecuteMerge(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)

func GetDocsInConflict

func GetDocsInConflict(ctx context.Context, workingRoot *doltdb.RootValue, docs doltdocs.Docs) (*diff.DocDiffs, error)

func GetTablesInConflict

func GetTablesInConflict(ctx context.Context, roots doltdb.Roots) (
	workingInConflict, stagedInConflict, headInConflict []string,
	err error,
)

func GetTablesWithConstraintViolations

func GetTablesWithConstraintViolations(ctx context.Context, roots doltdb.Roots) (
	workingViolations, stagedViolations, headViolations []string,
	err error,
)

func MayHaveConstraintViolations

func MayHaveConstraintViolations(ctx context.Context, ancestor, merged *doltdb.RootValue) (bool, error)

MayHaveConstraintViolations returns whether the given roots may have constraint violations. For example, a fast forward merge that does not involve any tables with foreign key constraints or check constraints will not be able to generate constraint violations. Unique key constraint violations would be caught during the generation of the merged root, therefore it is not a factor for this function.

func MergeBase

func MergeBase(ctx context.Context, left, right *doltdb.Commit) (base hash.Hash, err error)

func MergeCommitSpec

func MergeCommitSpec(ctx context.Context, dEnv *env.DoltEnv, spec *MergeSpec) (map[string]*MergeStats, error)

TODO forcing a commit with a constrain violation should warn users that subsequest

FF merges will not surface constraint violations on their own; constraint verify --all
is required to reify violations.

func MergeCommits

func MergeCommits(ctx context.Context, commit, mergeCommit *doltdb.Commit, opts editor.Options) (*doltdb.RootValue, map[string]*MergeStats, error)

func MergeRoots

func MergeRoots(ctx context.Context, ourRoot, theirRoot, ancRoot *doltdb.RootValue, opts editor.Options) (*doltdb.RootValue, map[string]*MergeStats, error)

func MergeWouldStompChanges

func MergeWouldStompChanges(ctx context.Context, roots doltdb.Roots, mergeCommit *doltdb.Commit) ([]string, map[string]hash.Hash, error)

func Ours

func Ours(key types.Value, cnf conflict.Conflict) (types.Value, error)

func ResolveTable

func ResolveTable(ctx context.Context, vrw types.ValueReadWriter, tblName string, root *doltdb.RootValue, autoResFunc AutoResolver, opts editor.Options) (*doltdb.RootValue, error)

func Revert

func Revert(ctx context.Context, ddb *doltdb.DoltDB, root *doltdb.RootValue, commits []*doltdb.Commit, opts editor.Options) (*doltdb.RootValue, string, error)

Revert is a convenience function for a three-way merge. In particular, given some root and a collection of commits that are all parents of the root value, this applies a three-way merge with the following characteristics (assuming a commit is HEAD~1):

Base: HEAD~1 Ours: root Theirs: HEAD~2

The root is updated with the merged result, and this process is repeated for each commit given, in the order given. Currently, we error on conflicts or constraint violations generated by the merge.

func Theirs

func Theirs(key types.Value, cnf conflict.Conflict) (types.Value, error)

Types

type AutoResolveStats

type AutoResolveStats struct {
}

type AutoResolver

type AutoResolver func(key types.Value, conflict conflict.Conflict) (types.Value, error)

type ChkConflict

type ChkConflict struct {
	Kind         conflictKind
	Ours, Theirs schema.Check
}

func (ChkConflict) String

func (c ChkConflict) String() string

type ColConflict

type ColConflict struct {
	Kind         conflictKind
	Ours, Theirs schema.Column
}

func (ColConflict) String

func (c ColConflict) String() string

type ConflictReader

type ConflictReader struct {
	// contains filtered or unexported fields
}

ConflictReader is a class providing a NextConflict function which can be used in a pipeline as a pipeline.SourceFunc, or it can be used to read each conflict

func NewConflictReader

func NewConflictReader(ctx context.Context, tbl *doltdb.Table) (*ConflictReader, error)

NewConflictReader returns a new conflict reader for a given table

func (*ConflictReader) Close

func (cr *ConflictReader) Close() error

Close should release resources being held

func (*ConflictReader) GetJoiner

func (cr *ConflictReader) GetJoiner() *rowconv.Joiner

GetJoiner returns the joiner used to join a row with its base, and merge versions

func (*ConflictReader) GetKeyForConflict

func (cr *ConflictReader) GetKeyForConflict(ctx context.Context, r row.Row) (types.Value, error)

GetKeyForConflicts returns the pk for a conflict row

func (*ConflictReader) GetSchema

func (cr *ConflictReader) GetSchema() schema.Schema

GetSchema gets the schema of the rows that this reader will return

func (*ConflictReader) NextConflict

NextConflict can be called successively to retrieve the conflicts in a table. Once all conflicts have been returned io.EOF will be returned in the error field. This can be used in a pipeline, or to iterate through all the conflicts in a table.

type ConflictSink

type ConflictSink struct {
	// contains filtered or unexported fields
}

func NewConflictSink

func NewConflictSink(wr io.WriteCloser, sch schema.Schema, colSep string) (*ConflictSink, error)

func (*ConflictSink) Close

func (cs *ConflictSink) Close() error

Close should release resources being held

func (*ConflictSink) GetSchema

func (cs *ConflictSink) GetSchema() schema.Schema

GetSchema gets the schema of the rows that this writer writes

func (*ConflictSink) ProcRowWithProps

func (cs *ConflictSink) ProcRowWithProps(r row.Row, props pipeline.ReadableMap) error

type ConflictSplitter

type ConflictSplitter struct {
	// contains filtered or unexported fields
}

ConflictsSplitter splits a conflict into base, ours, and their version of a row

func NewConflictSplitter

func NewConflictSplitter(ctx context.Context, vrw types.ValueReadWriter, joiner *rowconv.Joiner) (ConflictSplitter, error)

NewConflictSplitter creates a new ConflictSplitter

func (ConflictSplitter) GetSchema

func (ds ConflictSplitter) GetSchema() schema.Schema

GetSchema returns the common schema which all rows will share

func (ConflictSplitter) SplitConflicts

func (ds ConflictSplitter) SplitConflicts(inRow row.Row, _ pipeline.ReadableMap) (rowData []*pipeline.TransformedRowResult, badRowDetails string)

SplitConflicts takes a conflict row and splits it into ours, theirs, and base versions and provides pipeline properties which can be used to distinguished which is which and what type of conflict occurred.

type FKConflict

type FKConflict struct {
	Kind         conflictKind
	Ours, Theirs doltdb.ForeignKey
}

func ForeignKeysMerge

func ForeignKeysMerge(ctx context.Context, mergedRoot, ourRoot, theirRoot, ancRoot *doltdb.RootValue) (*doltdb.ForeignKeyCollection, []FKConflict, error)

ForeignKeysMerge performs a three-way merge of (ourRoot, theirRoot, ancRoot) and using mergeRoot to validate FKs.

type IdxConflict

type IdxConflict struct {
	Kind         conflictKind
	Ours, Theirs schema.Index
}

func (IdxConflict) String

func (c IdxConflict) String() string

type MergeSpec

type MergeSpec struct {
	HeadH        hash.Hash
	MergeH       hash.Hash
	HeadC        *doltdb.Commit
	MergeC       *doltdb.Commit
	TblNames     []string
	WorkingDiffs map[string]hash.Hash
	Squash       bool
	Msg          string
	Noff         bool
	Force        bool
	AllowEmpty   bool
	Email        string
	Name         string
	Date         time.Time
}

func NewMergeSpec

func NewMergeSpec(ctx context.Context, rsr env.RepoStateReader, ddb *doltdb.DoltDB, roots doltdb.Roots, name, email, msg string, commitSpecStr string, squash bool, noff bool, force bool, date time.Time) (*MergeSpec, bool, error)

type MergeStats

type MergeStats struct {
	Operation            TableMergeOp
	Adds                 int
	Deletes              int
	Modifications        int
	Conflicts            int
	ConstraintViolations int
}

type MergeVersion

type MergeVersion int

MergeVersion defines which version a value of a row corresponds to

const (
	// BaseVersion represents the state of a row at the most recent ancestor
	BaseVersion MergeVersion = iota
	// OurVersion represents the state of a row on our branch that is being merged into
	OurVersion
	// TheirVersion represents the state of a row on their branch which we are merging
	TheirVersion
	// Blank is used for displaying a row without a version label
	Blank
)

type Merger

type Merger struct {
	// contains filtered or unexported fields
}

func NewMerger

func NewMerger(ctx context.Context, root, mergeRoot, ancRoot *doltdb.RootValue, vrw types.ValueReadWriter) *Merger

NewMerger creates a new merger utility object.

func (*Merger) MergeTable

func (merger *Merger) MergeTable(ctx context.Context, tblName string, opts editor.Options) (*doltdb.Table, *MergeStats, error)

MergeTable merges schema and table data for the table tblName.

type MutableSecondaryIdx

type MutableSecondaryIdx struct {
	Name string
	// contains filtered or unexported fields
}

MutableSecondaryIdx wraps a prolly.MutableMap of a secondary table index. It provides the InsertEntry, UpdateEntry, and DeleteEntry functions which can be used to modify the index based on a modification to corresponding primary row.

func NewMutableSecondaryIdx

func NewMutableSecondaryIdx(m prolly.Map, sch schema.Schema, index schema.Index, syncPool pool.BuffPool) MutableSecondaryIdx

NewMutableSecondaryIdx returns a MutableSecondaryIdx. |m| is the secondary idx data.

func (MutableSecondaryIdx) DeleteEntry

func (m MutableSecondaryIdx) DeleteEntry(ctx context.Context, key val.Tuple, value val.Tuple) error

DeleteEntry deletes a secondary index entry given they key and value of the primary row.

func (MutableSecondaryIdx) InsertEntry

func (m MutableSecondaryIdx) InsertEntry(ctx context.Context, key, newValue val.Tuple) error

InsertEntry inserts a secondary index entry given the key and new value of the primary row.

func (MutableSecondaryIdx) Map

Map returns the finalized prolly.Map of the underlying prolly.MutableMap.

func (MutableSecondaryIdx) UpdateEntry

func (m MutableSecondaryIdx) UpdateEntry(ctx context.Context, key, currValue, newValue val.Tuple) error

UpdateEntry modifies the corresponding secondary index entry given the key and curr/new values of the primary row.

type SchemaConflict

type SchemaConflict struct {
	TableName    string
	ColConflicts []ColConflict
	IdxConflicts []IdxConflict
	ChkConflicts []ChkConflict
}

func SchemaMerge

func SchemaMerge(ourSch, theirSch, ancSch schema.Schema, tblName string) (sch schema.Schema, sc SchemaConflict, err error)

SchemaMerge performs a three-way merge of ourSch, theirSch, and ancSch.

func (SchemaConflict) AsError

func (sc SchemaConflict) AsError() error

func (SchemaConflict) Count

func (sc SchemaConflict) Count() int

type TableMergeOp

type TableMergeOp int
const (
	TableUnmodified TableMergeOp = iota
	TableAdded
	TableRemoved
	TableModified
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL