MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / findAncestorFromSet

Method findAncestorFromSet

db/revtree.go:380–395  ·  view source on GitHub ↗

Given a revision and a set of possible ancestors, finds the one that is the most recent ancestor of the revision; if none are ancestors, returns "".

(revid string, ancestors []string)

Source from the content-addressed store, hash-verified

378// Given a revision and a set of possible ancestors, finds the one that is the most recent
379// ancestor of the revision; if none are ancestors, returns "".
380func (tree RevTree) findAncestorFromSet(revid string, ancestors []string) string {
381 // OPT: This is slow...
382 for revid != "" {
383 for _, a := range ancestors {
384 if a == revid {
385 return a
386 }
387 }
388 info, err := tree.getInfo(revid)
389 if err != nil {
390 break
391 }
392 revid = info.Parent
393 }
394 return ""
395}
396
397// Records a revision in a RevTree.
398func (tree RevTree) addRevision(docid string, info RevInfo) error {

Calls 1

getInfoMethod · 0.95

Tested by

no test coverage detected