Merge pull request #481 from arv/counter

Don't read the current commit from the datastore
This commit is contained in:
Erik Arvidsson
2015-10-26 16:38:32 -04:00
+5 -7
View File
@@ -70,7 +70,7 @@ func (ds *dataStoreCommon) doCommit(datasetID string, commit Commit) bool {
if commitRef.Equals(currentHeadRef) {
return true
}
if !descendsFrom(commitRef, currentHeadRef, ds) {
if !descendsFrom(commit, currentHeadRef, ds) {
return false
}
}
@@ -83,9 +83,9 @@ func (ds *dataStoreCommon) doCommit(datasetID string, commit Commit) bool {
return ds.UpdateRoot(newRootRef, currentRootRef)
}
func descendsFrom(commitRef, currentHeadRef RefOfCommit, cs chunks.ChunkSource) bool {
func descendsFrom(commit Commit, currentHeadRef RefOfCommit, cs chunks.ChunkSource) bool {
// BFS because the common case is that the ancestor is only a step or two away
ancestors := NewSetOfRefOfCommit().Insert(commitRef)
ancestors := commit.Parents()
for !ancestors.Has(currentHeadRef) {
if ancestors.Empty() {
return false
@@ -97,11 +97,9 @@ func descendsFrom(commitRef, currentHeadRef RefOfCommit, cs chunks.ChunkSource)
func getAncestors(commits SetOfRefOfCommit, cs chunks.ChunkSource) SetOfRefOfCommit {
ancestors := NewSetOfRefOfCommit()
commits.Iter(func(r RefOfCommit) (stop bool) {
commits.IterAll(func(r RefOfCommit) {
c := r.TargetValue(cs)
ancestors =
ancestors.Union(c.Parents())
return
ancestors = ancestors.Union(c.Parents())
})
return ancestors
}