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

Moves -getRevPrefix: from DatastoreCrud to CloudantSyncTests

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.
Removes some unused code and fixes a re-declaration of the 'winningRev'
object within the block. All tests pass this change in my local copy.
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.
Exposes the getDocument:...database: method to public.

This is necessary for performing conflict resolutions when multiple queries
and inserts to the database within a single transaction are necessary. Performing all
operations within an single transaction ensures database integrity in the case of an
error during the operation. Within a single transaction in the case of an error,
the database may be "rolled back" to its original state.
Fixes the call for returning conflicting revisions of a document.

* Adds CDTDatastore+Internal for CDTDatastore methods we wish to keep private.
  -  moves CDTDatastore+Conflicts -conflictsForDocumentId to CDTDatastore+Internal
-activeRevisionsForDocumentId. An "active revision" of a document is defined as
a terminal (leaf) node in a document revision tree that is not deleted. For example,
given the following revision tree for a document

    ----- 2-c (current = 1, deleted = 1)
  /
1-a --- 2-a --- 3-a (current = 1, deleted = 0)
  \
    ---- 2-b (current = 1, deleted = 0)

the active revisions are 3-a and 2-b. The 'current' and 'deleted' are column names
in underlying SQLite tables.

* Fixes bug in SQL query in TD_Database+Conflicts that finds documents with conflicts.
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.
Modifies TD_Database -getAllRevisionsOfDocumentID with excludeDeleted parameter

* Adds an additional parameter to exclude deleted documents in the output from
TD_Database -getAllRevisionsOFDocumetnID. This was added so as to be able to return
just the active revisions of a document (all non-deleted leaf nodes) -- a conservative
approach to keep changes to a minimum. Instead of completely changing this method,
a excludeDeleted:NO call allows the method to behave as before this commit.

When calling -getAllRevisionsOfDocumentID:anId onlyCurrent:YES excludeDeleted: YES,
one will get all conflicting revisions for a particular document (as opposed to
the previous behavior of getting all revisions with current=1)

TD_Database getAllRevionsOfDocumentID is used by CDTDatastore+Internal
-activeRevisionsForDocumentId:(NSString*) and thus this fixes a bug, where deleted
leaf nodes were mistakenly being included in the returned NSArray*.

* All uses of this method, and related methods, were subsequently modified.

* Fixes a bug in TD_Database -extraPropertiesForRevision that used
-getAllRevisionsOfDocumentID to get all conflicting revisions.

The tests in DatastoreConflicts were modified appropriately.
Adds a few more tests for dealing with conflicts.

Cleans up some compiler warnings in due to unused variables and
method declarations (TDInternal.h)