Standard CouchDB encoding of a revision list: digests without numeric generation prefixes go in the "ids" property, and the first (largest) generation number in the "start" property. The docID parameter is informational only - and used when logging edge cases.
(ctx context.Context, docID string, revs []string)
| 830 | // the "ids" property, and the first (largest) generation number in the "start" property. |
| 831 | // The docID parameter is informational only - and used when logging edge cases. |
| 832 | func encodeRevisions(ctx context.Context, docID string, revs []string) Revisions { |
| 833 | ids := make([]string, len(revs)) |
| 834 | var start int |
| 835 | for i, revid := range revs { |
| 836 | gen, id := ParseRevID(ctx, revid) |
| 837 | ids[i] = id |
| 838 | if i == 0 { |
| 839 | start = gen |
| 840 | } else if gen != start-i { |
| 841 | base.DebugfCtx(ctx, base.KeyCRUD, "Found gap in revision list for doc %q. Expecting gen %v but got %v in %v", base.UD(docID), start-i, gen, revs) |
| 842 | } |
| 843 | } |
| 844 | return Revisions{RevisionsStart: start, RevisionsIds: ids} |
| 845 | } |
| 846 | |
| 847 | // Given a revision history encoded by encodeRevisions() and a list of possible ancestor revIDs, |
| 848 | // trim the history to stop at the first ancestor revID. If no ancestors are found, trim to |