Add runtime failure message for impossible situations

This commit is contained in:
Neil Macneale IV
2024-02-11 13:03:44 -08:00
parent 49f7dc4390
commit 4fdf404e39
53 changed files with 103 additions and 112 deletions
+1 -1
View File
@@ -434,7 +434,7 @@ func (dArgs *diffArgs) applyDiffRoots(queryist cli.Queryist, sqlCtx *sql.Context
fromRef := args[0]
// treat the first arg as a ref spec
_, err := getTableNamesAtRef(queryist, sqlCtx, fromRef)
if errors.Is(err, doltdb.ErrUnexpectedGhostCommit) {
if errors.Is(err, doltdb.ErrGhostCommitEncountered) {
return nil, err
}
// if it doesn't resolve, treat it as a table name
+1 -1
View File
@@ -158,7 +158,7 @@ func writeResultSet(ctx *sql.Context, rowIter sql.RowIter, wr table.SqlRowWriter
i := 0
for {
r, err := rowIter.Next(ctx)
if err == io.EOF || err == doltdb.ErrUnexpectedGhostCommit {
if err == io.EOF || err == doltdb.ErrGhostCommitEncountered {
break
} else if err != nil {
return 0, err
+1 -1
View File
@@ -201,7 +201,7 @@ func getNerf(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgParseResu
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
return rebase.StopAtCommit(cm), nil
+1 -1
View File
@@ -223,7 +223,7 @@ func getRemoteDBAtCommit(ctx context.Context, remoteUrl string, remoteUrlParams
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, nil, errhand.BuildDError(doltdb.ErrUnexpectedGhostCommit.Error()).Build()
return nil, nil, errhand.BuildDError(doltdb.ErrGhostCommitEncountered.Error()).Build()
}
srcRoot, err := cm.GetRootValue(ctx)
+1 -1
View File
@@ -284,7 +284,7 @@ func printObjects(ctx context.Context, dEnv *env.DoltEnv, opts *showOpts) error
}
commit, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
value := commit.Value()
+1 -1
View File
@@ -150,7 +150,7 @@ func applyStashAtIdx(ctx *sql.Context, dEnv *env.DoltEnv, curWorkingRoot *doltdb
if !ok {
// Should not be possible to get into this situation. The parent of the stashed commit
// Must have been present at the time it was created
return false, doltdb.ErrUnexpectedGhostCommit
return false, doltdb.ErrGhostCommitEncountered
}
parentRoot, err := parentCommit.GetRootValue(ctx)
+1 -1
View File
@@ -233,7 +233,7 @@ func stashChanges(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgPars
}
commit, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
commitMeta, err := commit.GetCommitMeta(ctx)
@@ -210,7 +210,7 @@ func cherryPick(ctx *sql.Context, dSess *dsess.DoltSession, roots doltdb.Roots,
}
cherryCommit, ok := optCmt.ToCommit()
if err != nil {
return nil, "", doltdb.ErrUnexpectedGhostCommit
return nil, "", doltdb.ErrGhostCommitEncountered
}
if len(cherryCommit.DatasParents()) > 1 {
@@ -233,7 +233,7 @@ func cherryPick(ctx *sql.Context, dSess *dsess.DoltSession, roots doltdb.Roots,
}
parentCommit, ok := optCmt.ToCommit()
if !ok {
return nil, "", doltdb.ErrUnexpectedGhostCommit
return nil, "", doltdb.ErrGhostCommitEncountered
}
parentRoot, err := parentCommit.GetRootValue(ctx)
+4 -3
View File
@@ -32,7 +32,8 @@ var errHasNoRootValue = errors.New("no root value")
// TODO: Include the commit id in the error. Unfortunately, this message is passed through the SQL layer. The only way we currently
// have on the client side to match an error is with string matching. We possibly need error codes as a prefix to the error message, but
// currently there is not standard for doing this in Dolt.
var ErrUnexpectedGhostCommit = errors.New("Commit not found. You are using a shallow clone which does not contain the requested commit. Please do a full clone.")
var ErrGhostCommitEncountered = errors.New("Commit not found. You are using a shallow clone which does not contain the requested commit. Please do a full clone.")
var ErrGhostCommitRuntimeFailure = errors.New("runtime failure: Ghost commit encountered unexpectedly. Please report bug to: https://github.com/dolthub/dolt/issues")
// Rootish is an object resolvable to a RootValue.
type Rootish interface {
@@ -237,7 +238,7 @@ func (c *Commit) CanFastReverseTo(ctx context.Context, new *Commit) (bool, error
ancestor, ok := optAnc.ToCommit()
if !ok {
return false, ErrUnexpectedGhostCommit
return false, ErrGhostCommitEncountered
}
if ancestor == nil {
return false, errors.New("cannot perform fast forward merge; commits have no common ancestor")
@@ -279,7 +280,7 @@ func (c *Commit) GetAncestor(ctx context.Context, as *AncestorSpec) (*OptionalCo
var ok bool
hardInst, ok = optInst.ToCommit()
if !ok {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
}
+1 -1
View File
@@ -151,7 +151,7 @@ func HashToCommit(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeSt
}
if dc.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
return NewCommit(ctx, vrw, ns, dc)
+6 -6
View File
@@ -436,7 +436,7 @@ func (ddb *DoltDB) BootstrapShallowResolve(ctx context.Context, cs *CommitSpec)
}
if commitValue.IsGhost() {
return prolly.CommitClosure{}, ErrUnexpectedGhostCommit
return prolly.CommitClosure{}, ErrGhostCommitEncountered
}
return getCommitClosure(ctx, commitValue, ddb.vrw, ddb.ns)
@@ -477,7 +477,7 @@ func (ddb *DoltDB) ResolveCommitRef(ctx context.Context, ref ref.DoltRef) (*Comm
}
if commitVal.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
return NewCommit(ctx, ddb.vrw, ddb.ns, commitVal)
@@ -501,7 +501,7 @@ func (ddb *DoltDB) ResolveCommitRefAtRoot(ctx context.Context, ref ref.DoltRef,
}
if commitVal.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
return NewCommit(ctx, ddb.vrw, ddb.ns, commitVal)
@@ -770,7 +770,7 @@ func (ddb *DoltDB) CommitWithParentSpecs(ctx context.Context, valHash hash.Hash,
hardCommit, ok := cm.ToCommit()
if !ok {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
parentCommits = append(parentCommits, hardCommit)
@@ -843,7 +843,7 @@ func (ddb *DoltDB) CommitValue(ctx context.Context, dref ref.DoltRef, val types.
}
if dc.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
return NewCommit(ctx, ddb.vrw, ddb.ns, dc)
@@ -1456,7 +1456,7 @@ func (ddb *DoltDB) CommitWithWorkingSet(
}
if dc.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
return NewCommit(ctx, ddb.vrw, ddb.ns, dc)
+2 -2
View File
@@ -64,7 +64,7 @@ func getStashList(ctx context.Context, ds datas.Dataset, vrw types.ValueReadWrit
}
if hc.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
headCommit, err := NewCommit(ctx, vrw, ns, hc)
@@ -119,7 +119,7 @@ func getStashAtIdx(ctx context.Context, ds datas.Dataset, vrw types.ValueReadWri
}
if hc.IsGhost() {
return nil, nil, nil, ErrUnexpectedGhostCommit
return nil, nil, nil, ErrGhostCommitEncountered
}
headCommit, err := NewCommit(ctx, vrw, ns, hc)
+1 -1
View File
@@ -44,7 +44,7 @@ func NewTag(ctx context.Context, name string, ds datas.Dataset, vrw types.ValueR
}
if dc.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
commit, err := NewCommit(ctx, vrw, ns, dc)
+2 -2
View File
@@ -407,7 +407,7 @@ func newWorkingSet(ctx context.Context, name string, vrw types.ValueReadWriter,
}
if fromDCommit.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
commit, err := NewCommit(ctx, vrw, ns, fromDCommit)
@@ -463,7 +463,7 @@ func newWorkingSet(ctx context.Context, name string, vrw types.ValueReadWriter,
}
if datasOntoCommit.IsGhost() {
return nil, ErrUnexpectedGhostCommit
return nil, ErrGhostCommitEncountered
}
ontoCommit, err := NewCommit(ctx, vrw, ns, datasOntoCommit)
+6 -6
View File
@@ -102,7 +102,7 @@ func CopyBranchOnDB(ctx context.Context, ddb *doltdb.DoltDB, oldBranch, newBranc
commit, ok := cm.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
return ddb.NewBranchAtCommit(ctx, newRef, commit, rsc)
}
@@ -194,7 +194,7 @@ func validateBranchMergedIntoCurrentWorkingBranch(ctx context.Context, dbdata en
}
branchHead, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
cwbCs, err := doltdb.NewCommitSpec("HEAD")
@@ -212,7 +212,7 @@ func validateBranchMergedIntoCurrentWorkingBranch(ctx context.Context, dbdata en
}
cwbHead, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
isMerged, err := branchHead.CanFastForwardTo(ctx, cwbHead)
@@ -262,7 +262,7 @@ func validateBranchMergedIntoUpstream(ctx context.Context, dbdata env.DbData, br
}
remoteBranchHead, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
optCmt, err = dbdata.Ddb.Resolve(ctx, cs, nil)
@@ -271,7 +271,7 @@ func validateBranchMergedIntoUpstream(ctx context.Context, dbdata env.DbData, br
}
localBranchHead, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
canFF, err := localBranchHead.CanFastForwardTo(ctx, remoteBranchHead)
@@ -341,7 +341,7 @@ func CreateBranchOnDB(ctx context.Context, ddb *doltdb.DoltDB, newBranch, starti
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
err = ddb.NewBranchAtCommit(ctx, branchRef, cm, rsc)
+1 -1
View File
@@ -242,7 +242,7 @@ func BranchHeadRoot(ctx context.Context, db *doltdb.DoltDB, brName string) (*dol
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
branchRoot, err := cm.GetRootValue(ctx)
+1 -1
View File
@@ -264,7 +264,7 @@ func fullClone(ctx context.Context, srcDB *doltdb.DoltDB, dEnv *env.DoltEnv, src
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
err = dEnv.DoltDB.DeleteAllRefs(ctx)
@@ -325,7 +325,6 @@ func (i *dotDotCommiterator) Next(ctx context.Context) (hash.Hash, *doltdb.Optio
commit, ok := nextC.commit.ToCommit()
if !ok {
// Preserve the Ghost commit. NM4 - TEST THIS PATH.
return nextC.hash, nextC.commit, nil
}
+5 -7
View File
@@ -230,7 +230,7 @@ func PushToRemoteBranch(ctx context.Context, rsr env.RepoStateReader, tempTableD
}
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
newCtx, cancelFunc := context.WithCancel(ctx)
@@ -416,7 +416,8 @@ func FetchRemoteBranch(
}
srcDBCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 This really should never happen. The source db is always expected to have everything.
// This really should never happen. The source db is always expected to have everything.
return nil, doltdb.ErrGhostCommitRuntimeFailure
}
// The code is structured this way (different paths for progress chan v. not) so that the linter can understand there
@@ -599,7 +600,7 @@ func fetchRefSpecsWithDepth(
}
commit, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit // NM4 - This definitely needs its own error message. TEST THIS PATH.
return doltdb.ErrGhostCommitEncountered // NM4 - This definitely needs its own error message. TEST THIS PATH.
}
remoteTrackRef := newHead.Ref
@@ -634,9 +635,6 @@ func fetchRefSpecsWithDepth(
}
if mode.Prune {
if remote == nil { // NM4 - I think this can be reverted. remote should never be nil.
return fmt.Errorf("Runtime error: remote is nil")
}
err = pruneBranches(ctx, dbData, *remote, newHeads)
if err != nil {
return err
@@ -700,7 +698,7 @@ func updateSkipList(ctx context.Context, srcDB *doltdb.DoltDB, toFetch []hash.Ha
// Must resolve because we just fetched it.
commit, ok := optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit
return nil, nil, doltdb.ErrGhostCommitEncountered
}
for i := 0; i < commit.NumParents(); i++ {
+2 -2
View File
@@ -53,7 +53,7 @@ func resetHardTables(ctx context.Context, dbData env.DbData, cSpecStr string, ro
var ok bool
if newHead, ok = optCmt.ToCommit(); !ok {
return nil, doltdb.Roots{}, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.Roots{}, doltdb.ErrGhostCommitEncountered
}
roots.Head, err = newHead.GetRootValue(ctx)
@@ -249,7 +249,7 @@ func ResetSoftToRef(ctx context.Context, dbData env.DbData, cSpecStr string) (do
}
newHead, ok := optCmt.ToCommit()
if !ok {
return doltdb.Roots{}, doltdb.ErrUnexpectedGhostCommit
return doltdb.Roots{}, doltdb.ErrGhostCommitEncountered
}
foundRoot, err := newHead.GetRootValue(ctx)
+1 -1
View File
@@ -67,7 +67,7 @@ func CreateTagOnDB(ctx context.Context, ddb *doltdb.DoltDB, tagName, startPoint
}
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit // NM4 - This probably needs a different message. Need a test for this one.
return doltdb.ErrGhostCommitEncountered
}
meta := datas.NewTagMeta(props.TaggerName, props.TaggerEmail, props.Description)
+7 -14
View File
@@ -69,7 +69,7 @@ func CreateWorkspaceOnDB(ctx context.Context, ddb *doltdb.DoltDB, name, startPoi
}
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit // Should never happen?? better error anyway. NM4 - Test?
return doltdb.ErrGhostCommitEncountered
}
return ddb.NewWorkspaceAtCommit(ctx, workRef, cm)
@@ -80,14 +80,10 @@ func IsWorkspaceOnDB(ctx context.Context, ddb *doltdb.DoltDB, str string) (bool,
return ddb.HasRef(ctx, dref)
}
/*
func IsWorkspace(ctx context.Context, dEnv *env.DoltEnv, str string) (bool, error) {
return IsWorkspaceOnDB(ctx, dEnv.DoltDB, str)
}
*/
/*
func DeleteWorkspace(ctx context.Context, dEnv *env.DoltEnv, workspaceName string, opts DeleteOptions) error {
var dref ref.DoltRef
if opts.Remote {
@@ -110,8 +106,6 @@ func DeleteWorkspace(ctx context.Context, dEnv *env.DoltEnv, workspaceName strin
return DeleteWorkspaceOnDB(ctx, dEnv, dref, opts)
}
func DeleteWorkspaceOnDB(ctx context.Context, dEnv *env.DoltEnv, dref ref.DoltRef, opts DeleteOptions) error {
ddb := dEnv.DoltDB
hasRef, err := ddb.HasRef(ctx, dref)
@@ -132,9 +126,9 @@ func DeleteWorkspaceOnDB(ctx context.Context, dEnv *env.DoltEnv, dref ref.DoltRe
if err != nil {
return err
}
m, err := optCmt.ToCommit()
if err != nil {
panic("NM4") // Should never happen?? better error anyway.
m, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrGhostCommitEncountered
}
cs, err := doltdb.NewCommitSpec(dref.String())
@@ -146,9 +140,9 @@ func DeleteWorkspaceOnDB(ctx context.Context, dEnv *env.DoltEnv, dref ref.DoltRe
if err != nil {
return err
}
cm, err := optCmt.ToCommit()
if err != nil {
panic("NM4") // Should never happen?? better error anyway.
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrGhostCommitEncountered
}
isMerged, _ := m.CanFastReverseTo(ctx, cm)
@@ -162,4 +156,3 @@ func DeleteWorkspaceOnDB(ctx context.Context, dEnv *env.DoltEnv, dref ref.DoltRe
return ddb.DeleteWorkspace(ctx, dref)
}
*/
+1 -1
View File
@@ -281,7 +281,7 @@ func mergeStateToMergeState(ctx context.Context, mergeState *mergeState, db *dol
commit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
pmwh := hash.Parse(mergeState.PreMergeWorking)
+2 -2
View File
@@ -106,7 +106,7 @@ func NewMergeSpec(
}
headCM, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - need better message. TEST THIS PATH.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - need better message. TEST THIS PATH.
}
mergeCS, err := doltdb.NewCommitSpec(commitSpecStr)
@@ -120,7 +120,7 @@ func NewMergeSpec(
}
mergeCM, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - need better message. TEST THIS PATH
return nil, doltdb.ErrGhostCommitEncountered // NM4 - need better message. TEST THIS PATH
}
headH, err := headCM.HashOf()
+1 -1
View File
@@ -54,7 +54,7 @@ func MergeCommits(ctx *sql.Context, commit, mergeCommit *doltdb.Commit, opts edi
}
ancCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - not sure if we can get to this point. TEST THIS PATH.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - not sure if we can get to this point. TEST THIS PATH.
}
ourRoot, err := commit.GetRootValue(ctx)
+1 -1
View File
@@ -29,7 +29,7 @@ func MergeBase(ctx context.Context, left, right *doltdb.Commit) (base hash.Hash,
}
ancestor, ok := optCmt.ToCommit()
if !ok {
return base, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST. I think getCommitAncestor is going to be an awk one.
return base, doltdb.ErrGhostCommitEncountered // NM4 - TEST. I think getCommitAncestor is going to be an awk one.
}
return ancestor.HashOf()
+1 -1
View File
@@ -66,7 +66,7 @@ func Revert(ctx *sql.Context, ddb *doltdb.DoltDB, root *doltdb.RootValue, commit
}
parentCM, ok := optCmt.ToCommit()
if !ok {
return nil, "", doltdb.ErrUnexpectedGhostCommit // NM4 - TEST THIS PATH.
return nil, "", doltdb.ErrGhostCommitEncountered // NM4 - TEST THIS PATH.
}
theirRoot, err := parentCM.GetRootValue(ctx)
+2 -2
View File
@@ -127,7 +127,7 @@ func migrateCommit(ctx context.Context, menv Environment, oldCm *doltdb.Commit,
}
oldParentCm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
oldParentRoot, err := oldParentCm.GetRootValue(ctx)
@@ -156,7 +156,7 @@ func migrateCommit(ctx context.Context, menv Environment, oldCm *doltdb.Commit,
}
newParentCm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
newParentRoot, err := newParentCm.GetRootValue(ctx)
+2 -2
View File
@@ -142,7 +142,7 @@ func traverseTagHistory(ctx context.Context, menv Environment, r ref.TagRef, old
}
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
return new.NewTagAtCommit(ctx, r, cm, t.Meta)
@@ -194,7 +194,7 @@ func traverseCommitHistory(ctx context.Context, menv Environment, cm *doltdb.Com
}
cm, ok = optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit
return doltdb.ErrGhostCommitEncountered
}
}
}
@@ -190,7 +190,7 @@ func rebaseRecursive(ctx context.Context, ddb *doltdb.DoltDB, replay ReplayCommi
for _, optParent := range allOptParents {
parent, ok := optParent.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST, surely needs a better error.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST, surely needs a better error.
}
allParents = append(allParents, parent)
}
+1 -1
View File
@@ -202,7 +202,7 @@ func findRebaseCommits(ctx *sql.Context, currentBranchCommit, upstreamBranchComm
commit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // Not sure if we can get this far. commit walk is going to be a bear.
return nil, doltdb.ErrGhostCommitEncountered // Not sure if we can get this far. commit walk is going to be a bear.
}
// Don't include merge commits in the rebase plan
+3 -3
View File
@@ -511,7 +511,7 @@ func resolveAsOfTime(ctx *sql.Context, ddb *doltdb.DoltDB, head ref.DoltRef, asO
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
h, err := cm.HashOf()
@@ -533,7 +533,7 @@ func resolveAsOfTime(ctx *sql.Context, ddb *doltdb.DoltDB, head ref.DoltRef, asO
}
curr, ok := optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
meta, err := curr.GetCommitMeta(ctx)
@@ -586,7 +586,7 @@ func resolveAsOfCommitRef(ctx *sql.Context, db Database, head ref.DoltRef, commi
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
root, err := cm.GetRootValue(ctx)
@@ -1087,7 +1087,7 @@ func resolveAncestorSpec(ctx *sql.Context, revSpec string, ddb *doltdb.DoltDB) (
ok := false
cm, ok = optCmt.ToCommit()
if !ok {
return "", doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return "", doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
hash, err := cm.HashOf()
@@ -1482,7 +1482,7 @@ func initialStateForCommit(ctx context.Context, srcDb ReadOnlyDatabase) (dsess.I
}
cm, ok := optCmt.ToCommit()
if !ok {
return dsess.InitialDbState{}, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST???
return dsess.InitialDbState{}, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST???
}
init := dsess.InitialDbState{
@@ -105,7 +105,7 @@ func resolveRefSpecs(ctx *sql.Context, leftSpec, rightSpec string) (left, right
}
left, ok = optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST, surely needs a better error.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST, surely needs a better error.
}
optCmt, err = doltDB.Resolve(ctx, rcs, headRef)
@@ -114,7 +114,7 @@ func resolveRefSpecs(ctx *sql.Context, leftSpec, rightSpec string) (left, right
}
right, ok = optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST, surely needs a better error.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST, surely needs a better error.
}
return
@@ -80,7 +80,7 @@ func (a *HasAncestor) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
}
headCommit, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
}
@@ -104,7 +104,7 @@ func (a *HasAncestor) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
}
ancCommit, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
}
@@ -91,7 +91,7 @@ func (t *HashOf) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
}
cm, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST this.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST this.
}
} else {
return nil, err
@@ -110,7 +110,7 @@ func (t *HashOf) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
}
cm, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
h, err := cm.HashOf()
@@ -337,7 +337,7 @@ func resolveCommit(ctx *sql.Context, ddb *doltdb.DoltDB, headRef ref.DoltRef, cS
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
return cm, nil
@@ -443,7 +443,7 @@ func (ltf *LogTableFunction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter
}
commit, ok = optCmt.ToCommit()
if err != nil {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
commits = append(commits, commit)
@@ -462,7 +462,7 @@ func (ltf *LogTableFunction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter
}
notCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
notCommits = append(notCommits, notCommit)
@@ -486,7 +486,7 @@ func (ltf *LogTableFunction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter
}
mergeCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
notCommits = append(notCommits, mergeCommit)
@@ -678,7 +678,7 @@ func (itr *logTableFunctionRowIter) Next(ctx *sql.Context) (sql.Row, error) {
ok := false
commit, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
if itr.tableNames != nil {
@@ -693,7 +693,7 @@ func (itr *logTableFunctionRowIter) Next(ctx *sql.Context) (sql.Row, error) {
}
parent0Cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
var parent1Cm *doltdb.Commit
@@ -704,7 +704,7 @@ func (itr *logTableFunctionRowIter) Next(ctx *sql.Context) (sql.Row, error) {
}
parent1Cm, ok = optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
}
@@ -82,7 +82,7 @@ func countCommits(ctx *sql.Context, args ...string) (ahead uint64, behind uint64
}
fromCommit, ok := optCmt.ToCommit()
if !ok {
return 0, 0, doltdb.ErrUnexpectedGhostCommit // NM4 - Have no idea what this is
return 0, 0, doltdb.ErrGhostCommitEncountered // NM4 - Have no idea what this is
}
fromHash, err := fromCommit.HashOf()
@@ -100,7 +100,7 @@ func countCommits(ctx *sql.Context, args ...string) (ahead uint64, behind uint64
}
toCommit, ok := optCmt.ToCommit()
if !ok {
return 0, 0, doltdb.ErrUnexpectedGhostCommit // NM4 - Have no idea what this is
return 0, 0, doltdb.ErrGhostCommitEncountered // NM4 - Have no idea what this is
}
toHash, err := toCommit.HashOf()
@@ -114,7 +114,7 @@ func countCommits(ctx *sql.Context, args ...string) (ahead uint64, behind uint64
}
ancestor, ok := optCmt.ToCommit()
if !ok {
return 0, 0, doltdb.ErrUnexpectedGhostCommit // NM4 - Have no idea what this is
return 0, 0, doltdb.ErrGhostCommitEncountered // NM4 - Have no idea what this is
}
ancestorHash, err := ancestor.HashOf()
@@ -199,7 +199,7 @@ func startRebase(ctx *sql.Context, upstreamPoint string) error {
}
upstreamCommit, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit // NM4 - prob user input. TEST. message.
return doltdb.ErrGhostCommitEncountered // NM4 - prob user input. TEST. message.
}
// rebaseWorkingBranch is the name of the temporary branch used when performing a rebase. In Git, a rebase
@@ -565,7 +565,7 @@ func squashCommitMessage(ctx *sql.Context, nextCommitHash string) (string, error
}
nextCommit, ok := optCmt.ToCommit()
if !ok {
return "", doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return "", doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
nextCommitMeta, err := nextCommit.GetCommitMeta(ctx)
@@ -104,7 +104,7 @@ func doDoltRevert(ctx *sql.Context, args []string) (int, error) {
}
commit, ok := optCmt.ToCommit()
if !ok {
return 1, doltdb.ErrUnexpectedGhostCommit // NM4 TEST - I think should never happen.
return 1, doltdb.ErrGhostCommitEncountered // NM4 TEST - I think should never happen.
}
commits[i] = commit
+3 -3
View File
@@ -415,7 +415,7 @@ func (d *DoltSession) newWorkingSetForHead(ctx *sql.Context, wsRef ref.WorkingSe
}
headCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit
return nil, doltdb.ErrGhostCommitEncountered
}
headRoot, err := headCommit.GetRootValue(ctx)
@@ -697,7 +697,7 @@ func (d *DoltSession) newPendingCommit(ctx *sql.Context, branchState *branchStat
}
parentCommit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST THIS PATH.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST THIS PATH.
}
mergeParentCommits = append(mergeParentCommits, parentCommit)
@@ -897,7 +897,7 @@ func (d *DoltSession) ResolveRootForRef(ctx *sql.Context, dbName, refStr string)
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, nil, "", doltdb.ErrUnexpectedGhostCommit
return nil, nil, "", doltdb.ErrGhostCommitEncountered
}
root, err = cm.GetRootValue(ctx)
@@ -208,7 +208,7 @@ func doltCommit(ctx *sql.Context,
}
curHead, ok := optCmt.ToCommit()
if !ok {
return nil, nil, doltdb.ErrUnexpectedGhostCommit // NM4 - def runtime error.
return nil, nil, doltdb.ErrGhostCommitEncountered // NM4 - def runtime error.
}
// We already got a new staged root via merge or ff via the doCommit method, so now apply it to the STAGED value
@@ -342,7 +342,7 @@ func (itr *doltColDiffCommitHistoryRowItr) Next(ctx *sql.Context) (sql.Row, erro
}
commit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST, message.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST, message.
}
err = itr.loadTableChanges(ctx, commit)
@@ -420,7 +420,7 @@ func (itr *doltColDiffCommitHistoryRowItr) calculateTableChanges(ctx context.Con
}
parent, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST, message.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST, message.
}
fromRootValue, err := parent.GetRootValue(ctx)
@@ -166,7 +166,7 @@ func (itr *CommitAncestorsRowItr) Next(ctx *sql.Context) (sql.Row, error) {
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - I think this will happen plenty. TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - I think this will happen plenty. TEST.
}
parents, err := itr.ddb.ResolveAllParents(ctx, cm)
@@ -183,7 +183,7 @@ func (itr *CommitAncestorsRowItr) Next(ctx *sql.Context) (sql.Row, error) {
for i, optParent := range parents {
p, ok := optParent.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
ph, err := p.HashOf()
@@ -271,7 +271,7 @@ func (dt *CommitDiffTable) rootValForHash(ctx *sql.Context, hashStr string) (*do
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, "", nil, doltdb.ErrUnexpectedGhostCommit
return nil, "", nil, doltdb.ErrGhostCommitEncountered
}
root, err = cm.GetRootValue(ctx)
@@ -156,7 +156,7 @@ func (itr CommitsRowItr) Next(ctx *sql.Context) (sql.Row, error) {
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
meta, err := cm.GetCommitMeta(ctx)
@@ -406,7 +406,7 @@ func (dt *DiffTable) reverseIterForChild(ctx *sql.Context, parent hash.Hash) (*d
childCm, ok := optCmt.ToCommit()
if !ok {
return nil, hash.Hash{}, doltdb.ErrUnexpectedGhostCommit
return nil, hash.Hash{}, doltdb.ErrGhostCommitEncountered
}
phs, err := childCm.ParentHashes(ctx)
@@ -518,7 +518,7 @@ func (dt *DiffTable) toCommitLookupPartitions(ctx *sql.Context, hashes []hash.Ha
}
pc, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
cmHashToTblInfo[pj] = toCmInfo
@@ -803,7 +803,7 @@ func (dps *DiffPartitions) Next(ctx *sql.Context) (sql.Partition, error) {
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
root, err := cm.GetRootValue(ctx)
@@ -238,7 +238,7 @@ func (itr *LogItr) Next(ctx *sql.Context) (sql.Row, error) {
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
meta, err := cm.GetCommitMeta(ctx)
@@ -109,7 +109,7 @@ func (dt *SchemaConflictsTable) PartitionRows(ctx *sql.Context, part sql.Partiti
}
base, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - NEED TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - NEED TEST.
}
baseRoot, err := base.GetRootValue(ctx)
@@ -337,7 +337,7 @@ func (itr *doltDiffCommitHistoryRowItr) Next(ctx *sql.Context) (sql.Row, error)
}
commit, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
err = itr.loadTableChanges(ctx, commit)
@@ -412,7 +412,7 @@ func (itr *doltDiffCommitHistoryRowItr) calculateTableChanges(ctx context.Contex
}
parent, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
fromRootValue, err := parent.GetRootValue(ctx)
+1 -1
View File
@@ -458,7 +458,7 @@ func (cp commitPartitioner) Next(ctx *sql.Context) (sql.Partition, error) {
}
cm, ok := optCmt.ToCommit()
if !ok {
return nil, doltdb.ErrUnexpectedGhostCommit // NM4 TEST.
return nil, doltdb.ErrGhostCommitEncountered // NM4 TEST.
}
return &commitPartition{h, cm}, nil
@@ -412,7 +412,7 @@ func (rrd ReadReplicaDatabase) createNewBranchFromRemote(ctx *sql.Context, remot
}
cm, ok := optCmt.ToCommit()
if !ok {
return doltdb.ErrUnexpectedGhostCommit // NM4 - TEST.
return doltdb.ErrGhostCommitEncountered // NM4 - TEST.
}
err = rrd.ddb.NewBranchAtCommit(ctx, remoteRef.Ref, cm, nil)