Documentation ¶
Index ¶
- func AutoResolveConflicts(conflicts map[string]MergeConflict, resolverName string) (map[string]MergeSolution, error)
- func PrepareDatabasesPostMerge(merged *model.Database) error
- func PrepareDatabasesPreMerge(left *model.Database, right *model.Database)
- func SolveConflictByChoosingLeft(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
- func SolveConflictByChoosingNewest(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
- func SolveConflictByChoosingRight(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
- func UpdateLRIDs(left interface{}, right interface{}, IDName string, changes IDChanges)
- type IDChanges
- func MergeBookmarks(left []*model.Bookmark, right []*model.Bookmark, ...) ([]*model.Bookmark, IDChanges, error)
- func MergeInputFields(left []*model.InputField, right []*model.InputField, ...) ([]*model.InputField, IDChanges, error)
- func MergeLocations(left []*model.Location, right []*model.Location) ([]*model.Location, IDChanges, error)
- func MergeNotes(left []*model.Note, right []*model.Note, ...) ([]*model.Note, IDChanges, error)
- func MergeTagMaps(left []*model.TagMap, right []*model.TagMap, ...) ([]*model.TagMap, IDChanges, error)
- func MergeTags(left []*model.Tag, right []*model.Tag, ...) ([]*model.Tag, IDChanges, error)
- func MergeUserMarkAndBlockRange(leftUM []*model.UserMark, leftBR []*model.BlockRange, ...) ([]*model.UserMark, []*model.BlockRange, IDChanges, error)
- type MergeConflict
- type MergeConflictError
- type MergeConflictSolver
- type MergeSide
- type MergeSolution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoResolveConflicts ¶
func AutoResolveConflicts(conflicts map[string]MergeConflict, resolverName string) (map[string]MergeSolution, error)
AutoResolveConflicts resolves mergeConflicts using the resolver indicated by resolverName.
func PrepareDatabasesPostMerge ¶
PrepareDatabasesPostMerge bundles function calls that check the integrity of the merged database and does some post-cleanup
func PrepareDatabasesPreMerge ¶
PrepareDatabasesPreMerge bundles function calls that are necessary for preparing the databases before merging.
func SolveConflictByChoosingLeft ¶
func SolveConflictByChoosingLeft(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
SolveConflictByChoosingLeft solves a MergeConflict by always choosing the left side
func SolveConflictByChoosingNewest ¶
func SolveConflictByChoosingNewest(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
SolveConflictByChoosingNewest solves a MergeConflict by always choosing the newest entry, which is detected by the `LastModified` field. It returns an error if the field does not exist
func SolveConflictByChoosingRight ¶
func SolveConflictByChoosingRight(conflicts map[string]MergeConflict) (map[string]MergeSolution, error)
SolveConflictByChoosingRight solves a MergeConflict by always choosing the right side
func UpdateLRIDs ¶
UpdateLRIDs updates a given ID (named by IDName) on the left and right slices of *model.Model according to the given IDChanges.
Types ¶
type IDChanges ¶
IDChanges represents the changed ids of two slices of a model type after a merge has happened, so dependent objects can be updated accordingly. So if the ID of an object of the left slice changed from id 5 to 20, it will be represented as: {5: 20}.
func MergeBookmarks ¶
func MergeBookmarks(left []*model.Bookmark, right []*model.Bookmark, conflictSolution map[string]MergeSolution) ([]*model.Bookmark, IDChanges, error)
MergeBookmarks tries to merge the left and right slices of Bookmarks. If there is a collision, it returns an error asking for specification how it should handle it.
func MergeInputFields ¶
func MergeInputFields(left []*model.InputField, right []*model.InputField, conflictSolution map[string]MergeSolution) ([]*model.InputField, IDChanges, error)
MergeInputFields tries to merge the left and right slice of InputField. If there is a collision, it returns an error asking for specification how it should handle it.
func MergeLocations ¶
func MergeLocations(left []*model.Location, right []*model.Location) ([]*model.Location, IDChanges, error)
MergeLocations merges two slices of Location into one and returns the merged locations together with a IDChanges struct indicating if the ID of a location has changed.
func MergeNotes ¶
func MergeNotes(left []*model.Note, right []*model.Note, conflictSolution map[string]MergeSolution) ([]*model.Note, IDChanges, error)
MergeNotes tries to merge the left and right slice of Note. If there is a collision, it returns an error asking for specification how it should handle it.
func MergeTagMaps ¶
func MergeTagMaps(left []*model.TagMap, right []*model.TagMap, conflictSolution map[string]MergeSolution) ([]*model.TagMap, IDChanges, error)
MergeTagMaps merges a left and right slice of TagMap. It automatically removes redundant entries and also makes sure that the position-order stays similar.
func MergeTags ¶
func MergeTags(left []*model.Tag, right []*model.Tag, conflictSolution map[string]MergeSolution) ([]*model.Tag, IDChanges, error)
MergeTags tries to merge the left and right slice of Tag. If there is a collision, it returns an error asking for specification how it should handle it.
func MergeUserMarkAndBlockRange ¶
func MergeUserMarkAndBlockRange(leftUM []*model.UserMark, leftBR []*model.BlockRange, rightUM []*model.UserMark, rightBR []*model.BlockRange, conflictSolution map[string]MergeSolution) ([]*model.UserMark, []*model.BlockRange, IDChanges, error)
MergeUserMarkAndBlockRange joins UserMarks and BlockRanges from both sides and tries to merge them. Afterwards it will update the IDs of UserMark and BlockRange and returns them separately againg. If there is a collision, it will try to solve it using duplicate detection and - if that fails - returns an error asking for specification how it should handle it. MergeConflicts will be returned as a joined UserMarkBlockRange struct to make it easier representing conflicts. The returned IDChanges indicate if a UserMarkID has changed in the merge process.
type MergeConflict ¶
MergeConflict represents two Models that collide because of the same UniqueKey or other similarities.
type MergeConflictError ¶
type MergeConflictError struct { Err string Conflicts map[string]MergeConflict }
MergeConflictError indicates that a conflict happened while trying to merge two slices of Model. It contains the conflicts in order for the caller to solve them.
func (MergeConflictError) Error ¶
func (e MergeConflictError) Error() string
type MergeConflictSolver ¶
type MergeConflictSolver func(map[string]MergeConflict) (map[string]MergeSolution, error)
MergeConflictSolver describes a function that is able to handle mergeConflicts semi-automatic