(#1988) - smarter upsert, only updates doc when necessary

You guys were right to say that upsert() had
code smell.  One of the dumb things it does
is update the document whether we need to
or not.

So in the case of persisted mapreduce,
every time you do query(), a new change is
written to the _local/dependentDbs doc,
which is pure waste. This fixes that.