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

Method addRevision

db/revtree.go:398–416  ·  view source on GitHub ↗

Records a revision in a RevTree.

(docid string, info RevInfo)

Source from the content-addressed store, hash-verified

396
397// Records a revision in a RevTree.
398func (tree RevTree) addRevision(docid string, info RevInfo) error {
399 revid := info.ID
400 if revid == "" {
401 return fmt.Errorf("doc: %v, RevTree addRevision, empty revid is illegal", docid)
402 }
403 if tree.contains(revid) {
404 return fmt.Errorf("doc: %v, RevTree addRevision, already contains rev %q", docid, revid)
405 }
406 if p := info.Parent; p != "" {
407 parent, ok := tree[p]
408 if !ok {
409 return fmt.Errorf("doc: %v, RevTree addRevision, parent id %q is missing", docid, p)
410 }
411 // we're adding a new child, so strip the channels from the parent - they're now superseded
412 parent.Channels = nil
413 }
414 tree[revid] = &info
415 return nil
416}
417
418func (tree RevTree) getRevisionBody(revid string, loader RevLoaderFunc) ([]byte, bool) {
419 if revid == "" {

Callers 15

importDocMethod · 0.80
TestAlignRevTreeHistoryFunction · 0.80
TestRevTreeAddRevisionFunction · 0.80
TestRevTreeWinningRevFunction · 0.80
addAndGetFunction · 0.80
addPruneAndGetFunction · 0.80

Calls 2

containsMethod · 0.95
ErrorfMethod · 0.80

Tested by 13

TestAlignRevTreeHistoryFunction · 0.64
TestRevTreeAddRevisionFunction · 0.64
TestRevTreeWinningRevFunction · 0.64
addAndGetFunction · 0.64
addPruneAndGetFunction · 0.64
addRevsFunction · 0.64