anchor.diff:            [], Docs),
   
       make_return_tuple({ok, Errors}).
  -
  -winner({_SeqNo1, _RevId1} = Theirs,
  -       {_SeqNo2, _RevId2} = Ours) ->
  -    winner_helper(Theirs, Ours);
  -winner({_SeqNo1, _NotDeleted1, _RevId1} = Theirs,
  -       {_SeqNo2, _NotDeleted2, _RevId3} = Ours) ->
  -    winner_helper(Theirs, Ours).
  -
  -winner_helper(Theirs, Ours) ->
  -    %% Ours can be equal to Theirs; in this case we prefer our revision to
  -    %% avoid excessive work
  -    case max(Theirs, Ours) of
  -        Ours ->
  -            ours;
  -        Theirs ->
  -            theirs
  -    end.
   
   do_update_replicated_doc(_Bucket, _VBucket,
                            #doc{id = <<?LOCAL_DOC_PREFIX, _/binary>>}) ->
  
positive.code:             {error, not_my_vbucket} ->
                  {error, {bad_request, not_my_vbucket}};
              {ok, {OurSeqNo, OurRevId}, Deleted, Props} ->
                  DocRevExt = {DocSeqNo, not(DocDeleted), DocRevId},
                  OurRevExt = {OurSeqNo, not(Deleted), OurRevId},
  
                  case winner(DocRevExt, OurRevExt) of
                      ours ->
                          ok;
                      theirs ->
                          {cas, CAS} = lists:keyfind(cas, 1, Props),
                          case DocDeleted of
                              true ->
  
negative.code:           end, [], JsonDocIdRevs),
      {ok, Results}.
  
  is_missing_rev(Bucket, VBucket, Id, RemoteMeta) ->
       case capi_utils:get_meta(Bucket, VBucket, Id) of
           {error, enoent, _CAS} ->
               true;
           {error, not_my_vbucket} ->
               throw({bad_request, not_my_vbucket});
           {ok, LocalMeta, _Deleted, _Props} ->
               %% we do not have any information about deletedness of
               %% the remote side thus we use only revisions to
               %% determine a winner
               case max(LocalMeta, RemoteMeta) of
                   %% if equal, prefer LocalMeta since in this case, no need
                   %% to replicate the remote item, hence put LocalMeta before
                   %% RemoteMeta.
                   LocalMeta ->
                       false;
                   RemoteMeta ->
                       true
               end
       end.
  
  
  %% In case of one or more errors, just return the first one. Otherwise,
  %% return ok. Also notice that in case of error, we return {ok, Error}. This is
  