daleharvey/pouchdb — pull request #931 by anowak (2013-09-13 10:03:39+00:00)
Title: (#789) - Count pending revisions in a correct way

When multiple conflicting revisions for some id were present on a remote
database, `pending` variable was incremented only by one to account for
the document itself, but it was then decremented for every conflicting
change. This effected in negative `pending` value, which in turn meant
that `completed` callback was never called (due to `pending === 0` being
false).

This change modifies semantic of `pending` variable to count revisions
to process instead of documents. Calculation of `docs_read` was changed
as well, because it should include all fetched documents, including
conflicting revisions - until now it was counting something else than
`docs_written`, so a situation when `docs_written !== docs_read` was
possible (which should not happen, in general, `docs_read ===
docs_written + docs_write_failures`).