In pursuit of issue #654, we want to be able to figure out all the
refs contained in a given Value, along with the Types of the Values to
which those refs point. Value.Chunks() _almost_ met those needs, but
it returned a slice of ref.Ref, which doesn't convey any type info.
To address this, this patch does two things:
1) RefBase embeds the Value interface, and
2) Chunks() now returns []types.RefBase
RefBase now provides Type() as well, by virtue of embedding Value, so
callers can just iterate through the slice returned from Chunks() and
gather type info for all the refs embedded in a given Value.
I went all the way and made RefBase a Value instead of just adding the
Type() method because both types.Ref and the generated Ref types are
actually all Values, and doing so allowed me to change the definition of
refBuilderFunc in package_registry.go to be more precise. It now returns
RefBase instead of just Value.
This patch is the first step in moving all reading and writing to the
DataStore API, so that we can validate data commited to Noms.
The big change here is that types.ReadValue() no longer exists and is
replaced with a ReadValue() method on DataStore. A similar
WriteValue() method deprecates types.WriteValue(), but fully removing
that is left for a later patch. Since a lot of code in the types
package needs to read and write values, but cannot import the datas
package without creating an import cycle, the types package exports
ValueReader and ValueWriter interfaces, which DataStore implements.
Thus, a DataStore can be passed to anything in the types package which
needs to read or write values (e.g. a collection constructor or
typed-ref)
Relatedly, this patch also introduces the DataSink interface, so that
some public-facing apis no longer need to provide a ChunkSink.
Towards #654
Ref Values now have a TargetRef() method that returns the ref.Ref of
the target the Value is referencing.
Note: This is a breaking change. In old code the Ref() of the Value was
the Ref of the underlying target.
Fixes#464
This makes the new typed serialization the default (the old
serialization is not used but the code has not been cleaned up yet).
Some things are no working in the new world:
Chunking - The compound list is not working correctly any more. The
Chunks method is having issues because it assumed things based on the
old implicit chunking.
Commit - uses a `Set(Commit)` which means that the parent commit is
embedded. We need to change that to be `Set(Ref(Commit))` so that the
parent commit is referenced instead.
I accidentally left this commented out at some point, and it rusted
a bit when I made the change to have walk.doTreeWalk() walk over
chunks rather than values. So, re-enable the tests and fix them.
The walk package contains walk.Some() and walk.All() which let you
walk the Chunk graph starting at a given Ref.
I also added GetReachabilitySetDiff(), which will determine which
refs in a given ChunkSource can be reached from one given ref, but not
the other.
Towards issue #82
It turns out these functions aren't actually generally useful,
because they deal in Values and Refs, while what we actually
want is to deal in chunks. So...
Revert "Settle big/small vs to/from ONCE AND FOR ALL"
This reverts commit f51c575cd2.
Revert "Add a naive Diff() function between two Values."
This reverts commit 662bc5e3c4.
Given two refs, we need to be able to determine the set of chunks
reachable from one that cannot be reached from the other. This patch
adds a naive implementation of this functionality that essentially walks
the value tree down from the values pointed to by two refs and compares them.
It also has a little command-line driver, but this may be removed.
Fixes issue #82