Better error if a pushed document fails to be saved

If remote _bulk_docs indicates an error saving a document,
(a) Map "unauthorized" message to 401 status (instead of default 502)
(b) Put the document's URL in the NSError object's userInfo.
Allow client to reset replication state

Setting the "reset" property in a replication request will cause the local checkpoint to be erased, meaning the next replication will start over from scratch (sequence 0).
The Mac demo app now has a menu item that exercises this.
Fixes #186.
Updated MYUtilities
Fix crash after resuming pull due to location change

Shouldn't create a new _pendingChanges when resuming activity, or it'll be out of sync with the _batcher.
(Found by @tleyden; see his patch in #190.)
Fixes #188.
Improve _compact to clear out SQLite WAL file

_compact wasn't really freeing space (at least not immediately) because the changes got appended to the SQLite write-ahead log file. So I extended the -compact method by having it issue a SQL pragma to flush the WAL, and then close and re-open the database. This resets the "___.touchdb-wal" file to zero length.
Fixes #189.
-[TD_Server close] should be synchronous

Closing the server at app quit time is currently a race condition because the -close call returns before the server thread has finished closing stuff, so the process might exit before it finishes. Fixed this by making the -close call synchronous. (Related to #189.)
Avoid race condition registering filters on startup

It was possible for a persistent push replication to start running on  startup before the app had a chance to install filter blocks.
This meant the replication would ignore the filter and send all documents, which is pretty bad.

* Changed TDPusher to make a missing filter function an error.
* Changed TD_Server to wait till the next runloop iteration to start the replicator, giving the caller time to set up filters and validations.
Fixes #193.
Bump project version # to 1.001
Make direct PUT to attachment URL work with streamed request body

This case was accidentally not fixed back in commit 7f24896.
Fixes #198.
Better retry behavior on failure to get password from keychain

For some reason TDSocketChangeTracker sometimes fails to get the password of the credential it's just looked up.
Added some fallback code to make a second attempt to reload the credential.
Also, if it fails to get the password it will clear the busted credential so that it can try to look it up again when it gets
the 401 response.
Fixes #195 ... I hope?
Fix unnecessary 401 challenges

MYURLUtils' method -my_credentialForRealm: is returning a credential with no persistence
when the URL has a baked-in username and password. This turns out to prevent NSURLConnection
from proactively sending the same credential on the next connection to the host, with the bad
effect that every connection initially gets a 401 and only then gets the credential and retries. This
slows down performance.
Fixed this by changing the persistence to NSURLCredentialPersistenceForSession.
I believe this fixes #197 in TouchDB.
Oops, wrong submodule commit ID for MYUtilities.
Fix an assertion failure in TDSocketChangeTracker

-start should just return NO if called when tracker is already running.
Fixes #196.
Bump version to 1.002 (1.0.1 candidate 2)
Prevent unsaved models from being dealloced

TDDatabase now keeps a set of all TDModels with unsaved changes (needsSave=YES).
This keeps them in memory, and also enables a new database method to save all models.
Replicator now proactively sends auth credentials on every request.

I think this will fix the remaining Cloudant errors (timeout / socket-closed errors pushing large docs).
Speculatively fixes #185.
Persistent TDReplication (public API) fixes

The public API for persistent replications Just Didn't Work At All.
Fixed it.
TDUITableSource improvements

* Added -rowAtIndexPath:.
* Implement UIDataSourceModelAssociation on iOS 6+.
Helpful validation logging

Enable TDValidation logging (-LogTDValidation YES) to get logs when docs fail validation.
Log messages include old and new doc contents and the error code and message.
merged from upstream