Create style-guide.md
Use MRDatabaseContentChecker to simplify database validation

This helps make our tests less verbose, and should make it
simpler to check database content more quickly, especially
more complicated databases.
Merge pull request #27 from cloudant/30440-db-checker

Use MRDatabaseContentChecker to simplify database validation
Add tests for database state after attachment manipulation
Merge pull request #29 from cloudant/30440-validate-attachmentsdb

Add tests for database state after attachment manipulation
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.
Adds the CDTDatastore+Conflicts -resolveConflictsForDocument code and tests.

The -resolveConflictsForDocument:resolver:error method is used by external developers
to facilitate conflict resolution. The caller of this method supplies a delegate object
to perform the resolution, while this method takes care to insert to the new revision
into the database and to ensure the document is no longer conflicted by adding a deleted
revision to the appropriate leaf nodes.

Adds DatastoreConflictResolvers.h and .m, which define example objects that
follow the CDTConflictResolver protocol and are used in these tests.

Adds the excludeDeleted: option to TD_Database -getAllRevisionsOfDocumentId. This
allows TD_Database to return all of the active current revisions for a document that
are not 'deleted'. This set of revisions are the confliction revisions of a document.
Fixes bug where the TDStatus variable was not set on error before returning.
This is a temporary commit and will be squashed.

This adds a few tests, which currently fail, to the conflicts test suite.

In particular, I don't understand the sequence ordering of attachments.
testCreateConflict and testCreateConflictWithAttachment print out
a docs/revs JOINed table and the attachments table. I would expect the sequence
number for the attachment to be 2 and not 3 (in -testCreateConflictWithAttachment)