Files
dolt/walk/diff.go
T
Chris Masone 0ba565fed6 Add walk package
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
2015-07-23 16:47:39 -07:00

22 lines
526 B
Go

package walk
import (
"github.com/attic-labs/noms/chunks"
"github.com/attic-labs/noms/ref"
)
// GetReachabilitySetDiff returns the refs of the chunks reachable from 'big' that cannot be reached from 'small'
func GetReachabilitySetDiff(small, big ref.Ref, cs chunks.ChunkSource) (refs []ref.Ref) {
smallRefs := map[ref.Ref]bool{}
All(small, cs, func(r ref.Ref) {
smallRefs[r] = true
})
Some(big, cs, func(r ref.Ref) (skip bool) {
if skip = smallRefs[r]; !skip {
refs = append(refs, r)
}
return
})
return
}