mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-19 11:29:41 -05:00
0ba565fed6
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
22 lines
526 B
Go
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
|
|
}
|