mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-02 11:30:13 -05:00
+12
-12
@@ -8,7 +8,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
@@ -64,13 +64,13 @@ func (s AWSStore) Root() ref.Ref {
|
||||
rootTablePrimaryKey: {S: aws.String(rootTablePrimaryKeyValue)},
|
||||
},
|
||||
})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
if len(result.Item) == 0 {
|
||||
return ref.Ref{}
|
||||
}
|
||||
|
||||
Chk.Equal(len(result.Item), 2)
|
||||
d.Chk.Equal(len(result.Item), 2)
|
||||
return ref.MustParse(*(result.Item[rootTableRef].S))
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ func (s AWSStore) UpdateRoot(current, last ref.Ref) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
Chk.NoError(awsErr)
|
||||
d.Chk.NoError(awsErr)
|
||||
} else {
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func (s AWSStore) Get(ref ref.Ref) (io.ReadCloser, error) {
|
||||
|
||||
func (s AWSStore) Put() ChunkWriter {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "")
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
h := ref.NewHash()
|
||||
return &awsChunkWriter{
|
||||
store: s,
|
||||
@@ -142,12 +142,12 @@ type awsChunkWriter struct {
|
||||
}
|
||||
|
||||
func (w *awsChunkWriter) Write(data []byte) (int, error) {
|
||||
Chk.NotNil(w.file, "Write() cannot be called after Ref() or Close().")
|
||||
d.Chk.NotNil(w.file, "Write() cannot be called after Ref() or Close().")
|
||||
return w.writer.Write(data)
|
||||
}
|
||||
|
||||
func (w *awsChunkWriter) Ref() (ref.Ref, error) {
|
||||
Chk.NoError(w.Close())
|
||||
d.Chk.NoError(w.Close())
|
||||
return ref.FromHash(w.hash), nil
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ func (w *awsChunkWriter) Close() error {
|
||||
if w.file == nil {
|
||||
return nil
|
||||
}
|
||||
Chk.NoError(w.file.Sync())
|
||||
d.Chk.NoError(w.file.Sync())
|
||||
_, err := w.file.Seek(0, 0)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
bucket := aws.String(w.store.bucket)
|
||||
key := aws.String(ref.FromHash(w.hash).String())
|
||||
@@ -176,9 +176,9 @@ func (w *awsChunkWriter) Close() error {
|
||||
Key: key,
|
||||
Body: w.file,
|
||||
})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
Chk.NoError(w.file.Close())
|
||||
d.Chk.NoError(w.file.Close())
|
||||
os.Remove(w.file.Name())
|
||||
w.file = nil
|
||||
return nil
|
||||
|
||||
+14
-14
@@ -11,7 +11,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -25,15 +25,15 @@ type FileStore struct {
|
||||
type mkdirAllFn func(path string, perm os.FileMode) error
|
||||
|
||||
func NewFileStore(dir, root string) FileStore {
|
||||
Chk.NotEmpty(dir)
|
||||
Chk.NotEmpty(root)
|
||||
Chk.NoError(os.MkdirAll(dir, 0700))
|
||||
d.Chk.NotEmpty(dir)
|
||||
d.Chk.NotEmpty(root)
|
||||
d.Chk.NoError(os.MkdirAll(dir, 0700))
|
||||
return FileStore{dir, path.Join(dir, root), os.MkdirAll}
|
||||
}
|
||||
|
||||
func readRef(file *os.File) ref.Ref {
|
||||
s, err := ioutil.ReadAll(file)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
if len(s) == 0 {
|
||||
return ref.Ref{}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (f FileStore) Root() ref.Ref {
|
||||
if os.IsNotExist(err) {
|
||||
return ref.Ref{}
|
||||
}
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
syscall.Flock(int(file.Fd()), syscall.LOCK_SH)
|
||||
defer file.Close()
|
||||
@@ -56,7 +56,7 @@ func (f FileStore) Root() ref.Ref {
|
||||
|
||||
func (f FileStore) UpdateRoot(current, last ref.Ref) bool {
|
||||
file, err := os.OpenFile(f.root, os.O_RDWR|os.O_CREATE, os.ModePerm)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
syscall.Flock(int(file.Fd()), syscall.LOCK_EX)
|
||||
defer file.Close()
|
||||
|
||||
@@ -100,12 +100,12 @@ type fileChunkWriter struct {
|
||||
}
|
||||
|
||||
func (w *fileChunkWriter) Write(data []byte) (int, error) {
|
||||
Chk.NotNil(w.buffer, "Write() cannot be called after Ref() or Close().")
|
||||
d.Chk.NotNil(w.buffer, "Write() cannot be called after Ref() or Close().")
|
||||
return w.writer.Write(data)
|
||||
}
|
||||
|
||||
func (w *fileChunkWriter) Ref() (ref.Ref, error) {
|
||||
Chk.NoError(w.Close())
|
||||
d.Chk.NoError(w.Close())
|
||||
return ref.FromHash(w.hash), nil
|
||||
}
|
||||
|
||||
@@ -122,18 +122,18 @@ func (w *fileChunkWriter) Close() error {
|
||||
}
|
||||
|
||||
err := w.mkdirAll(path.Dir(p), 0700)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
file, err := os.OpenFile(p, os.O_RDWR|os.O_CREATE, os.ModePerm)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
Chk.True(os.IsExist(err), "%+v\n", err)
|
||||
d.Chk.True(os.IsExist(err), "%+v\n", err)
|
||||
}
|
||||
|
||||
totalBytes := w.buffer.Len()
|
||||
written, err := io.Copy(file, w.buffer)
|
||||
Chk.NoError(err)
|
||||
Chk.True(int64(totalBytes) == written, "Too few bytes written.") // BUG #83
|
||||
d.Chk.NoError(err)
|
||||
d.Chk.True(int64(totalBytes) == written, "Too few bytes written.") // BUG #83
|
||||
|
||||
w.buffer = nil
|
||||
return nil
|
||||
@@ -141,7 +141,7 @@ func (w *fileChunkWriter) Close() error {
|
||||
|
||||
func getPath(root string, ref ref.Ref) string {
|
||||
s := ref.String()
|
||||
Chk.True(strings.HasPrefix(s, "sha1"))
|
||||
d.Chk.True(strings.HasPrefix(s, "sha1"))
|
||||
return path.Join(root, "sha1", s[5:7], s[7:9], s)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ func (w *memoryChunkWriter) Write(data []byte) (int, error) {
|
||||
}
|
||||
|
||||
func (w *memoryChunkWriter) Ref() (ref.Ref, error) {
|
||||
dbg.Chk.NoError(w.Close())
|
||||
d.Chk.NoError(w.Close())
|
||||
return w.ref, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package chunks
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMemoryStorePut(t *testing.T) {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ type NopStore struct {
|
||||
|
||||
// Get panics in NopStore! Since the data wasn't stored, you sure can't Get it.
|
||||
func (ms *NopStore) Get(ref ref.Ref) (io.ReadCloser, error) {
|
||||
dbg.Chk.Fail("Whoops, you shouldn't have called this!")
|
||||
d.Chk.Fail("Whoops, you shouldn't have called this!")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -14,9 +14,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/garyburd/go-oauth/oauth"
|
||||
)
|
||||
@@ -107,22 +107,22 @@ func checkAuth() bool {
|
||||
|
||||
func authUser() {
|
||||
l, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 0})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
callbackURL := "http://" + l.Addr().String()
|
||||
tempCred, err := oauthClient.RequestTemporaryCredentials(nil, callbackURL, url.Values{
|
||||
"perms": []string{"read"},
|
||||
})
|
||||
// If we ever hear anything from the oauth handshake, it'll be acceptance. The user declining will mean we never get called.
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
authUrl := oauthClient.AuthorizationURL(tempCred, nil)
|
||||
fmt.Printf("Go to the following URL to authorize: %v\n", authUrl)
|
||||
err = awaitOAuthResponse(l, tempCred)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
if !checkAuth() {
|
||||
Chk.Fail("checkAuth failed after oauth succeded")
|
||||
d.Chk.Fail("checkAuth failed after oauth succeded")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func getAlbum(id string) {
|
||||
"photoset_id": id,
|
||||
"user_id": user.Id().String(),
|
||||
})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
fmt.Printf("\nPhotoset: %v\n", response.Photoset.Title)
|
||||
|
||||
@@ -176,7 +176,7 @@ func getAlbums() {
|
||||
}{}
|
||||
|
||||
err := callFlickrAPI("flickr.photosets.getList", &response, nil)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
for _, p := range response.Photosets.Photoset {
|
||||
getAlbum(p.Id)
|
||||
@@ -201,7 +201,7 @@ func getAlbumPhotos(id string) SetOfPhoto {
|
||||
"user_id": user.Id().String(),
|
||||
"extras": "tags",
|
||||
})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
photos := types.NewSet()
|
||||
for _, p := range response.Photoset.Photo {
|
||||
@@ -210,7 +210,7 @@ func getAlbumPhotos(id string) SetOfPhoto {
|
||||
photoReader := getPhotoReader(url)
|
||||
defer photoReader.Close()
|
||||
b, err := types.NewBlob(photoReader)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
photo := NewPhoto().
|
||||
SetId(types.NewString(p.Id)).
|
||||
SetTitle(types.NewString(p.Title)).
|
||||
@@ -219,7 +219,7 @@ func getAlbumPhotos(id string) SetOfPhoto {
|
||||
SetImage(b)
|
||||
// The photo is big, so write it out now to release the memory.
|
||||
r, err := types.WriteValue(photo.NomsValue(), ds)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
photos = photos.Insert(types.Ref{r})
|
||||
}
|
||||
return SetOfPhotoFromVal(photos)
|
||||
@@ -253,20 +253,20 @@ func getOriginalUrl(id string) string {
|
||||
err := callFlickrAPI("flickr.photos.getSizes", &response, &map[string]string{
|
||||
"photo_id": id,
|
||||
})
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
for _, p := range response.Sizes.Size {
|
||||
if p.Label == "Original" {
|
||||
return p.Source
|
||||
}
|
||||
}
|
||||
Chk.Fail(fmt.Sprintf("No Original image size found photo: %v", id))
|
||||
d.Chk.Fail(fmt.Sprintf("No Original image size found photo: %v", id))
|
||||
return "NOT REACHED"
|
||||
}
|
||||
|
||||
func getPhotoReader(url string) io.ReadCloser {
|
||||
resp, err := httpClient.Get(url)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return resp.Body
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ func callFlickrAPI(method string, response interface{}, args *map[string]string)
|
||||
|
||||
defer res.Body.Close()
|
||||
buff, err := ioutil.ReadAll(res.Body)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
if err = json.Unmarshal(buff, response); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -422,4 +422,3 @@ func (s User) OAuthSecret() types.String {
|
||||
func (s User) SetOAuthSecret(p types.String) User {
|
||||
return UserFromVal(s.m.Set(types.NewString("oAuthSecret"), p))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/sync"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func main() {
|
||||
if started, err := util.MaybeStartCPUProfile(); started {
|
||||
defer util.StopCPUProfile()
|
||||
} else if err != nil {
|
||||
dbg.Chk.NoError(err, "Can't create cpu profile file.")
|
||||
d.Chk.NoError(err, "Can't create cpu profile file.")
|
||||
}
|
||||
|
||||
newHead := source.Heads().Ref()
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ func processPitches(v types.Value) (pitches []Pitch) {
|
||||
case nil:
|
||||
return // Yes, an at-bat can end with no pitches thrown.
|
||||
default:
|
||||
dbg.Chk.Fail("No pitch should be %+v, which is of type %s!\n", v, reflect.TypeOf(v).String())
|
||||
d.Chk.Fail("No pitch should be %+v, which is of type %s!\n", v, reflect.TypeOf(v).String())
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func getIndex(input types.List) MapOfStringToListOfPitch {
|
||||
if pitchers.Has(id) {
|
||||
namedPitchCounts = namedPitchCounts.Set(pitchers.Get(id), p)
|
||||
} else {
|
||||
dbg.Chk.Fail("Unknown pitcher!", id)
|
||||
d.Chk.Fail("Unknown pitcher!", id)
|
||||
}
|
||||
return
|
||||
})
|
||||
@@ -158,7 +158,7 @@ func main() {
|
||||
if started, err := util.MaybeStartCPUProfile(); started {
|
||||
defer util.StopCPUProfile()
|
||||
} else if err != nil {
|
||||
dbg.Chk.NoError(err, "Can't create cpu profile file.")
|
||||
d.Chk.NoError(err, "Can't create cpu profile file.")
|
||||
}
|
||||
|
||||
dataStore := datas.NewDataStore(cs)
|
||||
|
||||
@@ -14,7 +14,7 @@ type ListOfPitch struct {
|
||||
l types.List
|
||||
}
|
||||
|
||||
type ListOfPitchIterCallback (func (p Pitch) (stop bool))
|
||||
type ListOfPitchIterCallback (func(p Pitch) (stop bool))
|
||||
|
||||
func NewListOfPitch() ListOfPitch {
|
||||
return ListOfPitch{types.NewList()}
|
||||
@@ -244,4 +244,3 @@ func (s Pitch) X() types.Float64 {
|
||||
func (s Pitch) SetX(p types.Float64) Pitch {
|
||||
return PitchFromVal(s.m.Set(types.NewString("X"), p))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -38,7 +38,7 @@ func main() {
|
||||
|
||||
types.All(inputRef, cs, func(f types.Future) {
|
||||
v, err := f.Deref(cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
if v, ok := v.(types.Map); ok && types.NewString("Photo").Equals(v.Get(types.NewString("$name"))) {
|
||||
p := PhotoFromVal(v)
|
||||
p.Tags().Iter(func(item types.String) (stop bool) {
|
||||
|
||||
@@ -300,4 +300,3 @@ func (s SetOfPhoto) fromElemSlice(p []Photo) []types.Value {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os/user"
|
||||
"path"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/gregjones/httpcache"
|
||||
"github.com/gregjones/httpcache/diskcache"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func CachingHttpClient() *http.Client {
|
||||
|
||||
if *diskCacheDir == defaultDiskCacheDir {
|
||||
user, err := user.Current()
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
*diskCacheDir = path.Join(user.HomeDir, "noms", "httpcache")
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ type stdoutChunkWriter struct {
|
||||
}
|
||||
|
||||
func (w *stdoutChunkWriter) Write(data []byte) (int, error) {
|
||||
dbg.Chk.NotNil(w.file, "Write() cannot be called after Ref() or Close().")
|
||||
d.Chk.NotNil(w.file, "Write() cannot be called after Ref() or Close().")
|
||||
return w.writer.Write(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package util
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ func NomsValueFromDecodedJSON(o interface{}) types.Value {
|
||||
}
|
||||
return out
|
||||
default:
|
||||
dbg.Chk.Fail("Nomsification failed.", "I don't understand %+v, which is of type %s!\n", o, reflect.TypeOf(o).String())
|
||||
d.Chk.Fail("Nomsification failed.", "I don't understand %+v, which is of type %s!\n", o, reflect.TypeOf(o).String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/attic-labs/noms/clients/util"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
"github.com/attic-labs/noms/dataset"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/clbanning/mxj"
|
||||
)
|
||||
@@ -67,7 +67,7 @@ func main() {
|
||||
}
|
||||
|
||||
ref, err := types.WriteValue(nomsObj, ds)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
list = list.Append(types.Ref{R: ref})
|
||||
return nil
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dbg
|
||||
package d
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+6
-6
@@ -2,7 +2,7 @@ package datas
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -28,8 +28,8 @@ func NewDataStoreWithRootTracker(cs chunks.ChunkStore, rt chunks.RootTracker) Da
|
||||
func newDataStoreInternal(cs chunks.ChunkStore, rt chunks.RootTracker, cc *commitCache) DataStore {
|
||||
if (rt.Root() == ref.Ref{}) {
|
||||
r, err := types.WriteValue(NewSetOfCommit().NomsValue(), cs)
|
||||
Chk.NoError(err)
|
||||
Chk.True(rt.UpdateRoot(r, ref.Ref{}))
|
||||
d.Chk.NoError(err)
|
||||
d.Chk.True(rt.UpdateRoot(r, ref.Ref{}))
|
||||
}
|
||||
return DataStore{
|
||||
cs, rt, cc, commitSetFromRef(rt.Root(), cs),
|
||||
@@ -47,7 +47,7 @@ func (ds *DataStore) Heads() SetOfCommit {
|
||||
|
||||
// Commit returns a new DataStore with newCommits as the heads, but backed by the same ChunkStore and RootTracker instances as the current one.
|
||||
func (ds *DataStore) Commit(newCommits SetOfCommit) DataStore {
|
||||
Chk.True(newCommits.Len() > 0)
|
||||
d.Chk.True(newCommits.Len() > 0)
|
||||
// TODO: We probably shouldn't let this go *forever*. Consider putting a limit and... I know don't...panicing?
|
||||
for !ds.doCommit(newCommits) {
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func (ds *DataStore) Commit(newCommits SetOfCommit) DataStore {
|
||||
|
||||
// doCommit manages concurrent access the single logical piece of mutable state: the set of current heads. doCommit is optimistic in that it is attempting to update heads making the assumption that currentRootRef is the ref of the current heads. The call to UpdateRoot below will fail if that assumption fails (e.g. because of a race with another writer) and the entire algorigthm must be tried again.
|
||||
func (ds *DataStore) doCommit(commits SetOfCommit) bool {
|
||||
Chk.True(commits.Len() > 0)
|
||||
d.Chk.True(commits.Len() > 0)
|
||||
|
||||
currentRootRef := ds.rt.Root()
|
||||
|
||||
@@ -85,7 +85,7 @@ func (ds *DataStore) doCommit(commits SetOfCommit) bool {
|
||||
|
||||
// TODO: This set will be orphaned if this UpdateRoot below fails
|
||||
newRootRef, err := types.WriteValue(newHeads.NomsValue(), ds)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
return ds.rt.UpdateRoot(newRootRef, currentRootRef)
|
||||
}
|
||||
|
||||
@@ -134,4 +134,3 @@ func (s Commit) Value() types.Value {
|
||||
func (s Commit) SetValue(p types.Value) Commit {
|
||||
return CommitFromVal(s.m.Set(types.NewString("value"), p))
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package mgmt
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/datas"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ func GetDatasets(ds datas.DataStore) SetOfDataset {
|
||||
return NewSetOfDataset()
|
||||
} else {
|
||||
// BUG 13: We don't ever want to branch the datasets database. Currently we can't avoid that, but we should change DataStore::Commit() to support that mode of operation.
|
||||
Chk.EqualValues(1, ds.Heads().Len())
|
||||
d.Chk.EqualValues(1, ds.Heads().Len())
|
||||
return SetOfDatasetFromVal(ds.Heads().Any().Value())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,4 +134,3 @@ func (s SetOfDataset) fromElemSlice(p []Dataset) []types.Value {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -27,7 +27,7 @@ func blobLeafDecode(src io.Reader) (io.Reader, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbg.Chk.True(bytes.Equal(buf.Bytes(), blobTag), "Cannot blobLeafDecode - invalid prefix")
|
||||
d.Chk.True(bytes.Equal(buf.Bytes(), blobTag), "Cannot blobLeafDecode - invalid prefix")
|
||||
|
||||
return src, nil
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,12 +25,12 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
)
|
||||
|
||||
// Encode serializes v into dst, and panics on unsupported types.
|
||||
func Encode(dst io.Writer, v interface{}) error {
|
||||
dbg.Chk.NotNil(dst)
|
||||
d.Chk.NotNil(dst)
|
||||
switch v := v.(type) {
|
||||
case io.Reader:
|
||||
return blobLeafEncode(dst, v)
|
||||
@@ -41,7 +41,7 @@ func Encode(dst io.Writer, v interface{}) error {
|
||||
|
||||
// Decode deserializes data from r into an interface{}, and panics on unsupported encoded types.
|
||||
func Decode(r io.Reader) (interface{}, error) {
|
||||
dbg.Chk.NotNil(r)
|
||||
d.Chk.NotNil(r)
|
||||
|
||||
// assumes all tags are same size, which they are for now.
|
||||
buffered := bufio.NewReaderSize(r, len(jsonTag))
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ func jsonDecode(reader io.Reader) (interface{}, error) {
|
||||
}
|
||||
|
||||
// Since jsonDecode is private, and Decode() should have checked this, it is invariant that the prefix will match.
|
||||
dbg.Chk.EqualValues(jsonTag[:], prefix, "Cannot jsonDecode - invalid prefix")
|
||||
d.Chk.EqualValues(jsonTag[:], prefix, "Cannot jsonDecode - invalid prefix")
|
||||
|
||||
var v interface{}
|
||||
err = json.NewDecoder(reader).Decode(&v)
|
||||
@@ -48,7 +48,7 @@ func jsonDecodeValue(v interface{}) (interface{}, error) {
|
||||
}
|
||||
|
||||
func jsonDecodeTaggedValue(m map[string]interface{}) (interface{}, error) {
|
||||
dbg.Chk.Len(m, 1)
|
||||
d.Chk.Len(m, 1)
|
||||
for k, v := range m {
|
||||
switch k {
|
||||
case "cb":
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ func (cb CompoundBlob) Len() uint64 {
|
||||
|
||||
// MapFromItems takes an even-numbered list of items and converts them into a stably-ordered map-like value by treating the even-indexed items as keys and the odd-indexed items as values, e.g. {e[0]: e[1], e[2]: e[3], ...}. This does NOT enforce key uniqueness.
|
||||
func MapFromItems(e ...interface{}) Map {
|
||||
dbg.Chk.True(0 == len(e)%2, "Length on input array must be multiple of 2")
|
||||
d.Chk.True(0 == len(e)%2, "Length on input array must be multiple of 2")
|
||||
return e
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ func getJSONCompoundBlob(cb CompoundBlob) (interface{}, error) {
|
||||
offset = cb.Offsets[i]
|
||||
}
|
||||
|
||||
dbg.Chk.Equal(len(l), len(cb.Blobs)*2)
|
||||
d.Chk.Equal(len(l), len(cb.Blobs)*2)
|
||||
|
||||
return map[string]interface{}{
|
||||
"cb": l,
|
||||
|
||||
+10
-10
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ type NG struct {
|
||||
|
||||
func New(outFile string) NG {
|
||||
f, err := os.OpenFile(outFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return NG{w: f, written: types.NewSet(), toWrite: types.NewSet()}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (ng *NG) AddType(val types.Value) types.Value {
|
||||
}
|
||||
ng.toWrite = ng.toWrite.Insert(val)
|
||||
default:
|
||||
Chk.Fail(fmt.Sprintf("Unexpected typedef: %+v", val))
|
||||
d.Chk.Fail(fmt.Sprintf("Unexpected typedef: %+v", val))
|
||||
}
|
||||
return val
|
||||
}
|
||||
@@ -81,15 +81,15 @@ func toNomsValue(name string) string {
|
||||
func readTemplate(name string) *template.Template {
|
||||
_, thisfile, _, _ := runtime.Caller(1)
|
||||
f, err := os.Open(path.Join(path.Dir(thisfile), name))
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
defer f.Close()
|
||||
b, err := ioutil.ReadAll(f)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
t, err := template.New(name).Funcs(template.FuncMap{
|
||||
"fromVal": fromNomsValue,
|
||||
"toVal": toNomsValue,
|
||||
}).Parse(string(b))
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return t
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func (ng *NG) writeType(val types.Map) {
|
||||
ng.writeStruct(val)
|
||||
return
|
||||
}
|
||||
Chk.Fail(fmt.Sprintf("Unexpected typedef: %+v", val))
|
||||
d.Chk.Fail(fmt.Sprintf("Unexpected typedef: %+v", val))
|
||||
}
|
||||
|
||||
func (ng *NG) writeSet(val types.Map) {
|
||||
@@ -216,7 +216,7 @@ func getGoStructName(typeDef types.Value) string {
|
||||
return strings.ToUpper(typeDef.String()[:2]) + typeDef.String()[2:]
|
||||
}
|
||||
|
||||
Chk.Fail("unexpected noms type name: %s", name)
|
||||
d.Chk.Fail("unexpected noms type name: %s", name)
|
||||
case types.Map:
|
||||
if typeDef.Has(types.NewString("$name")) {
|
||||
return typeDef.Get(types.NewString("$name")).(types.String).String()
|
||||
@@ -232,10 +232,10 @@ func getGoStructName(typeDef types.Value) string {
|
||||
case "noms.SetDef":
|
||||
return fmt.Sprintf("SetOf%s", getGoStructName(typeDef.Get(types.NewString("elem"))))
|
||||
case "noms.StructDef":
|
||||
Chk.Fail("noms.StructDef must have a $name filed: %+v", typeDef)
|
||||
d.Chk.Fail("noms.StructDef must have a $name filed: %+v", typeDef)
|
||||
}
|
||||
}
|
||||
Chk.Fail("Unexpected typeDef struct: %+v", typeDef)
|
||||
d.Chk.Fail("Unexpected typeDef struct: %+v", typeDef)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ type ListOfInt32 struct {
|
||||
l types.List
|
||||
}
|
||||
|
||||
type ListOfInt32IterCallback (func (p types.Int32) (stop bool))
|
||||
type ListOfInt32IterCallback (func(p types.Int32) (stop bool))
|
||||
|
||||
func NewListOfInt32() ListOfInt32 {
|
||||
return ListOfInt32{types.NewList()}
|
||||
@@ -400,4 +400,3 @@ func (s SetOfBool) fromElemSlice(p []types.Bool) []types.Value {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@ import (
|
||||
"hash"
|
||||
"regexp"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -41,7 +41,7 @@ func NewHash() hash.Hash {
|
||||
}
|
||||
|
||||
func FromHash(h hash.Hash) Ref {
|
||||
Chk.Equal(sha1.Size, h.Size())
|
||||
d.Chk.Equal(sha1.Size, h.Size())
|
||||
digest := Sha1Digest{}
|
||||
h.Sum(digest[:0])
|
||||
return New(digest)
|
||||
@@ -60,22 +60,22 @@ func Parse(s string) (r Ref, err error) {
|
||||
}
|
||||
|
||||
// If there was no error, we should have decoded exactly one digest worth of bytes.
|
||||
Chk.Equal(sha1.Size, n)
|
||||
d.Chk.Equal(sha1.Size, n)
|
||||
return
|
||||
}
|
||||
|
||||
func MustParse(s string) Ref {
|
||||
r, err := Parse(s)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return r
|
||||
}
|
||||
|
||||
// Less compares two Refs, returning true if the first is less than the second.
|
||||
// This can be called a lot, so performance and avoiding creating garbage may be important.
|
||||
// Particularly, Chk.Equals{Value} does reflection, and this can be expensive, so avoid it here.
|
||||
// Particularly, d.Chk.Equals{Value} does reflection, and this can be expensive, so avoid it here.
|
||||
func Less(r1, r2 Ref) bool {
|
||||
d1, d2 := r1.digest, r2.digest
|
||||
Chk.True(len(d1) == len(d2)) // BUG #83
|
||||
d.Chk.True(len(d1) == len(d2)) // BUG #83
|
||||
for k := 0; k < len(d1); k++ {
|
||||
b1, b2 := d1[k], d2[k]
|
||||
if b1 < b2 {
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ func futuresEqual(f1, f2 Future) bool {
|
||||
}
|
||||
|
||||
func futureEqualsValue(f Future, v Value) bool {
|
||||
Chk.NotNil(v)
|
||||
d.Chk.NotNil(v)
|
||||
if f.Val() != nil {
|
||||
return f.Val().Equals(v)
|
||||
} else {
|
||||
@@ -41,7 +41,7 @@ func futureEqualsValue(f Future, v Value) bool {
|
||||
|
||||
func futureFromValue(v Value) Future {
|
||||
if r, ok := v.(Ref); ok {
|
||||
return &unresolvedFuture{ref:r.Ref()}
|
||||
return &unresolvedFuture{ref: r.Ref()}
|
||||
} else {
|
||||
return resolvedFuture{v}
|
||||
}
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -40,11 +40,11 @@ func main() {
|
||||
func readTemplate(name string) *template.Template {
|
||||
_, thisfile, _, _ := runtime.Caller(1)
|
||||
f, err := os.Open(path.Join(path.Dir(thisfile), name))
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
defer f.Close()
|
||||
b, err := ioutil.ReadAll(f)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
t, err := template.New(name).Parse(string(b))
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return t
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ func getRef(v Value) ref.Ref {
|
||||
func getRefNoOverride(v Value) ref.Ref {
|
||||
r, err := WriteValue(v, chunks.NopStore{})
|
||||
// This can never fail because NopStore doesn't write anywhere.
|
||||
Chk.Nil(err)
|
||||
d.Chk.Nil(err)
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (l List) Empty() bool {
|
||||
func (l List) Get(idx uint64) Value {
|
||||
v, err := l.list[idx].Deref(l.cs)
|
||||
// This is the kind of thing that makes me feel like hiding deref'ing is probably not the right idea. But we'll go with it for now.
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return v
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -4,7 +4,7 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ func (fm Map) Get(key Value) Value {
|
||||
entry := fm.m[idx]
|
||||
if futureEqualsValue(entry.key, key) {
|
||||
v, err := entry.value.Deref(fm.cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return v
|
||||
}
|
||||
}
|
||||
@@ -75,9 +75,9 @@ type mapIterCallback func(key, value Value) bool
|
||||
func (fm Map) Iter(cb mapIterCallback) {
|
||||
for _, entry := range fm.m {
|
||||
k, err := entry.key.Deref(fm.cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
v, err := entry.value.Deref(fm.cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
if cb(k, v) {
|
||||
break
|
||||
}
|
||||
@@ -119,8 +119,8 @@ func newMapFromData(m mapData, cs chunks.ChunkSource) Map {
|
||||
}
|
||||
|
||||
func buildMapData(oldData mapData, futures []Future) mapData {
|
||||
// Sadly, Chk.Equals() costs too much. BUG #83
|
||||
Chk.True(0 == len(futures)%2, "Must specify even number of key/value pairs")
|
||||
// Sadly, d.Chk.Equals() costs too much. BUG #83
|
||||
d.Chk.True(0 == len(futures)%2, "Must specify even number of key/value pairs")
|
||||
|
||||
m := make(mapData, len(oldData), len(oldData)+len(futures))
|
||||
copy(m, oldData)
|
||||
|
||||
@@ -204,4 +204,3 @@ func (v Float64) Chunks() []Future {
|
||||
func Float64FromVal(v Value) Float64 {
|
||||
return v.(Float64)
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -5,14 +5,14 @@ import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/enc"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
// ReadValue reads and decodes a value from a chunk source. It is not considered an error for the requested chunk to be absent from cs; in this case, the function simply returns nil, nil.
|
||||
func ReadValue(r ref.Ref, cs chunks.ChunkSource) (Value, error) {
|
||||
dbg.Chk.NotNil(cs)
|
||||
d.Chk.NotNil(cs)
|
||||
reader, err := cs.Get(r)
|
||||
if reader != nil {
|
||||
defer reader.Close()
|
||||
@@ -69,7 +69,7 @@ func fromEncodeable(i interface{}, cs chunks.ChunkSource) (Future, error) {
|
||||
return futureFromRef(i), nil
|
||||
case io.Reader:
|
||||
data, err := ioutil.ReadAll(i)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return futureFromValue(newBlobLeaf(data)), nil
|
||||
case []interface{}:
|
||||
return futureListFromIterable(i, cs)
|
||||
@@ -89,7 +89,7 @@ func fromEncodeable(i interface{}, cs chunks.ChunkSource) (Future, error) {
|
||||
cb := compoundBlob{i.Offsets, blobs, &ref.Ref{}, cs}
|
||||
return futureFromValue(cb), nil
|
||||
default:
|
||||
dbg.Chk.Fail("Unknown encodeable", "%+v", i)
|
||||
d.Chk.Fail("Unknown encodeable", "%+v", i)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -132,6 +132,6 @@ func futuresFromIterable(items []interface{}, cs chunks.ChunkSource) (f []Future
|
||||
|
||||
func MustReadValue(ref ref.Ref, cs chunks.ChunkSource) Value {
|
||||
val, err := ReadValue(ref, cs)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return val
|
||||
}
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ func (fm Set) Iter(cb setIterCallback) {
|
||||
// TODO: sort iteration order
|
||||
for _, f := range fm.m {
|
||||
v, err := f.Deref(fm.cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
if cb(v) {
|
||||
break
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (fm Set) Iter(cb setIterCallback) {
|
||||
func (fm Set) Any() Value {
|
||||
for _, f := range fm.m {
|
||||
v, err := f.Deref(fm.cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return v
|
||||
}
|
||||
return nil
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ func doTreeWalk(f Future, cs chunks.ChunkSource, cb SomeCallback) {
|
||||
return
|
||||
}
|
||||
v, err := f.Deref(cs)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
|
||||
switch v := v.(type) {
|
||||
case Map:
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
. "github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestWalkAll(t *testing.T) {
|
||||
|
||||
write := func(v Value) Value {
|
||||
_, err := WriteValue(v, cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestWalkAll(t *testing.T) {
|
||||
expected := t.expected
|
||||
All(t.v.Ref(), cs, func(f Future) {
|
||||
v, err := f.Deref(cs)
|
||||
Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
assert.True(expected.Has(v))
|
||||
expected = expected.Remove(v)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/enc"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
)
|
||||
@@ -12,7 +12,7 @@ type primitive interface {
|
||||
}
|
||||
|
||||
func WriteValue(v Value, cs chunks.ChunkSink) (ref.Ref, error) {
|
||||
dbg.Chk.NotNil(cs)
|
||||
d.Chk.NotNil(cs)
|
||||
|
||||
e, err := toEncodeable(v, cs)
|
||||
if err != nil {
|
||||
@@ -128,7 +128,7 @@ func processChild(f Future, cs chunks.ChunkSink) (interface{}, error) {
|
||||
}
|
||||
|
||||
v := f.Val()
|
||||
dbg.Chk.NotNil(v)
|
||||
d.Chk.NotNil(v)
|
||||
switch v := v.(type) {
|
||||
// Blobs, lists, maps, and sets are always out-of-line
|
||||
case Blob, List, Map, Set:
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package walk
|
||||
|
||||
import (
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
)
|
||||
@@ -33,7 +33,7 @@ func doTreeWalk(r ref.Ref, cs chunks.ChunkSource, cb SomeCallback) {
|
||||
return
|
||||
}
|
||||
v, err := types.ReadValue(r, cs)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
for _, cf := range v.Chunks() {
|
||||
doTreeWalk(cf.Ref(), cs, cb)
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/attic-labs/noms/chunks"
|
||||
"github.com/attic-labs/noms/dbg"
|
||||
"github.com/attic-labs/noms/d"
|
||||
"github.com/attic-labs/noms/ref"
|
||||
"github.com/attic-labs/noms/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@@ -34,7 +34,7 @@ func (suite *WalkAllTestSuite) walkWorker(r ref.Ref, expected int) {
|
||||
|
||||
func (suite *WalkAllTestSuite) storeAndRef(v types.Value) (r ref.Ref) {
|
||||
r, err := types.WriteValue(v, suite.cs)
|
||||
dbg.Chk.NoError(err)
|
||||
d.Chk.NoError(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user