engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engine holds the operations that combine snapshots: three-way merges of trees and the rebase step used when landing changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conflict

type Conflict struct {
	Path   string
	Kind   ConflictKind
	Base   object.File // zero if the file did not exist in base
	Ours   object.File // zero if ours deleted it
	Theirs object.File // zero if theirs deleted it
	// Markers is the file with diff3-style conflict markers, for content
	// and add/add conflicts on text files.
	Markers []byte
	Detail  string
}

Conflict is one path that needs a decision.

type ConflictKind

type ConflictKind string

ConflictKind names why a path could not be merged.

const (
	ConflictContent      ConflictKind = "content"       // both sides edited the same lines
	ConflictAddAdd       ConflictKind = "add/add"       // both sides created the file differently
	ConflictModifyDelete ConflictKind = "modify/delete" // ours edited, theirs deleted
	ConflictDeleteModify ConflictKind = "delete/modify" // ours deleted, theirs edited
	ConflictMode         ConflictKind = "mode"          // both sides changed the mode differently
	ConflictBinary       ConflictKind = "binary"        // both sides changed a binary file
	ConflictPath         ConflictKind = "path"          // a file and a directory collide
)

type MergeResult

type MergeResult struct {
	// Tree is the merged root tree. It is Zero when there are conflicts.
	Tree hash.Hash
	// Conflicts lists paths that could not be merged.
	Conflicts []Conflict
	// AutoMerged lists paths both sides changed that merged line by line.
	AutoMerged []string
}

MergeResult is the outcome of MergeTrees.

func MergeTrees

func MergeTrees(ctx context.Context, s blob.Store, base, ours, theirs hash.Hash, labels merge.Labels) (MergeResult, error)

MergeTrees merges ours and theirs, which both descend from base. Paths changed on one side take that side. Paths changed on both sides are merged line by line when possible. With conflicts, the result has no tree.

func MergeTreesKeepConflicts

func MergeTreesKeepConflicts(ctx context.Context, s blob.Store, base, ours, theirs hash.Hash, labels merge.Labels) (MergeResult, error)

MergeTreesKeepConflicts is MergeTrees for a working copy: it always returns a tree. Text conflicts are written into the file with conflict markers; other conflicts keep our side. The caller shows the conflicts and the person or agent resolves them in place.

func (MergeResult) Clean

func (r MergeResult) Clean() bool

Clean reports whether the merge has no conflicts.

Jump to

Keyboard shortcuts

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