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

Method addNewerRevisionsToRevTreeHistory

db/crud.go:3826–3842  ·  view source on GitHub ↗

addNewerRevisionsToRevTreeHistory will add any newer rev tree id's to the local document history

(newDoc *Document, currentRevIndex int, parent string, docHistory []string)

Source from the content-addressed store, hash-verified

3824
3825// addNewerRevisionsToRevTreeHistory will add any newer rev tree id's to the local document history
3826func (doc *Document) addNewerRevisionsToRevTreeHistory(newDoc *Document, currentRevIndex int, parent string, docHistory []string) (string, error) {
3827 // currentRevIndex here is the index of the incoming rev tree list to start from.
3828 for i := currentRevIndex - 1; i >= 0; i-- {
3829 err := doc.History.addRevision(newDoc.ID,
3830 RevInfo{
3831 ID: docHistory[i],
3832 Parent: parent, // set the parent of this revision to the element of docHistory from the last iteration
3833 Deleted: i == 0 && newDoc.Deleted})
3834
3835 if err != nil {
3836 return "", err
3837 }
3838 parent = docHistory[i]
3839 }
3840 // return last element added from docHistory, this will be the doc's new current rev for writes that are aligning rev tree
3841 return parent, nil
3842}
3843
3844const (
3845 xattrMacroCas = "cas" // SyncData.Cas

Callers 2

Calls 1

addRevisionMethod · 0.80

Tested by

no test coverage detected