revTreeConflictCheck checks for conflicts in the rev tree history and returns the parent revid, currentRevIndex (index of parent rev), and an error if the document is in conflict
(ctx context.Context, revTreeHistory []string, doc *Document, newDocDeleted bool)
| 1783 | // revTreeConflictCheck checks for conflicts in the rev tree history and returns the parent revid, currentRevIndex |
| 1784 | // (index of parent rev), and an error if the document is in conflict |
| 1785 | func (db *DatabaseCollectionWithUser) revTreeConflictCheck(ctx context.Context, revTreeHistory []string, doc *Document, newDocDeleted bool) (string, int, error) { |
| 1786 | currentRevIndex := len(revTreeHistory) |
| 1787 | parent := "" |
| 1788 | if currentRevIndex > 0 { |
| 1789 | for i, revid := range revTreeHistory { |
| 1790 | if doc.History.contains(revid) { |
| 1791 | currentRevIndex = i |
| 1792 | parent = revid |
| 1793 | break |
| 1794 | } |
| 1795 | } |
| 1796 | // conflict check on rev tree history |
| 1797 | if db.IsIllegalConflict(ctx, doc, parent, newDocDeleted, true, revTreeHistory) { |
| 1798 | return "", 0, base.HTTPErrorf(http.StatusConflict, "Document revision conflict") |
| 1799 | } |
| 1800 | } |
| 1801 | return parent, currentRevIndex, nil |
| 1802 | } |
| 1803 | |
| 1804 | func buildResolverBody(localDoc, incomingDoc *Document) (Body, Body, error) { |
| 1805 | localRevID := localDoc.SyncData.GetRevTreeID() |