Accept being passed nil as error in -getDocumentWithId:...
Fix replicating attachments with revpos > doc generation

This is an import from:

couchbase/couchbase-lite-ios@b5ecc07c8688a5d834992a51a23cd99faf8be0db
Add shared methods for remote db code in ReplicationAcceptance
Use local CouchDB instance for all attachment replication tests
Use NSData rather than NSInputStream in attachments API

This was changed for a couple of reasons: gzipped attachments
and general API trends external to the library.

* Supporting gzipped attachments

This also allows us to inflate gzipped attachments before
returning data to client.

Some content types are zipped before storing on disk during
replication (or they come compressed from CouchDB and saved
to disk without removing the compression).

This paves the way for us to compress certain types when
added through the Cloudant Sync API.

* Why NSData rather than NSInputStream?

The iOS and OSX APIs appear to generally prefer working with either
NSData (e.g., UIImage imageWithData:) or file paths/URLs (e.g.,
UIImage imageWithContentsOfFile:). So providing NSInputStream
interfaces, while potentially more efficient, seemed like it would
be an overhead -- people would be forever writing these to files or
NSData objects anyway.

* Tests

Test which replicates gzipped data from remote database. We
need to fix exposing this data through our attachments API.
Open CDTDatastore's underlying TD_Database on -init

This helps to make sure initialisation code is only called
from one thread.
Allow results of -getAllDocuments to be used in -attachmentsForRev:...

-attachmentsForRev:... makes use of the sequence number, which
wasn't added to the TD_Revision by -getAllDocuments.
Allow comparing attachments of documents in a local and remote db
Add further attachment tests to ReplicationAcceptance

testReplicateManyLocalAttachments tests creating lots of local
attachments are successfully replicated.

testAddLocalReplicateDeleteLocalReplicate checks that deleting an
attachment from a local document that's already been replicated
remotely is replicated during a future replication.

testReplicateRemoteDocumentUpdate tests that updates to an
attachment are replicated correctly.

testReplicateRemoteDocumentDeleteLocalCheckReplicated tests that
deleting an attachment is replicated correctly.

testReplicateRemoteDocumentDeleteRemoteCheckReplicated tests that
deleting a remote attachment is replicated correctly.
Add a rake command to run ReplicationAcceptance tests
Add a rake command to pod update all projects
Significant cleanup of ReplicationAcceptance attachments tests
Merge pull request #28 from cloudant/30441-replication-attachments

30441 Add tests for replicating attachments to ReplicationAcceptance
10,000 replicated documents is probably enough in ReplicationAcceptance

And it's quicker too.
Allow ReplicationAcceptance tests to be run on devices

By adding an app to the project.
Merge pull request #30 from cloudant/28972-device-acceptance-tests

28972 Allow running ReplicationAcceptance tests on physical device
Adds CDTConflictResolver protocol
Adds TD_Database+Conflicts, which provides low-level interaction to conflicted documents.

Adds CDTDatastore+Conflicts
* wraps TD_Database+Conflicts -getConflictedDocumentIds
* moves conflictsForDocument from CDTDatastore to here
* implements enumerateConflictsUsingBlock (private)

Adds DatastoreConflicts tests

Replaces -getRevPrefix with TD_Revision generationFromRevID

There's a bit of code commented out in this commit as it's not quite ready. There
are some changes to TD_Database+Insertion that I want to do incrementally but don't
want to deal with the removing this code for later.
Breaks out a putRevision method to be used within a database transaction.

Adds TD_Database+Insertion -putRevision: winningRev: prevRevisionID: allowConflict
status: database:
This also fixes a bug regarding the winningRev pointer. Previously, winningRev
was always nil. This never seemed to affect database behavior because winningRev
is only used for notification purposes. This fix seems to be what the original
author indented and also seems to match the functionality of current CBL code.

Adds a few checks in DatastoreCrud for nil content of a CDTDocumentRevision object,
which was useful when finding bugs while breaking out -putRevision:..database
Fixes inTransaction so that it behaves as intended. rollback was set to
YES when the TDStatus was not an error.