Example #1
0
func (ds *Dataset) validateRefAsCommit(r ref.Ref) datas.Commit {
	v := ds.store.ReadValue(r)

	d.Exp.NotNil(v, "%v cannot be found", r)
	d.Exp.True(v.Type().Equals(datas.NewCommit().Type()), "Not a Commit: %+v", v)
	return v.(datas.Commit)
}
Example #2
0
// CommitWithParents updates the commit that a dataset points at. The new Commit is constructed using v and p.
// If the update cannot be performed, e.g., because of a conflict, CommitWithParents returns an 'ErrMergeNeeded' error and the current snapshot of the dataset so that the client can merge the changes and try again.
func (ds *Dataset) CommitWithParents(v types.Value, p datas.SetOfRefOfCommit) (Dataset, error) {
	newCommit := datas.NewCommit().SetParents(p).SetValue(v)
	store, err := ds.Store().Commit(ds.id, newCommit)
	return Dataset{store, ds.id}, err
}