Records a revision in a RevTree.
(docid string, info RevInfo)
| 396 | |
| 397 | // Records a revision in a RevTree. |
| 398 | func (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 | |
| 418 | func (tree RevTree) getRevisionBody(revid string, loader RevLoaderFunc) ([]byte, bool) { |
| 419 | if revid == "" { |