anchor.diff:      end.
   
   
  -calculate_start_seq(Db, #shard{node=Node, name=Name}, LocalId) ->
  -    case couch_db:open_doc(Db, LocalId, [ejson_body]) of
  -    {ok, #doc{body = {SProps}}} ->
  -        Opts = [{user_ctx, ?CTX}, {io_priority, {internal_repl, Name}}],
  -        try rexi_call(Node, {fabric_rpc, open_doc, [Name, LocalId, Opts]}) of
  -        #doc{body = {TProps}} ->
  -            SourceSeq = couch_util:get_value(<<"seq">>, SProps, 0),
  -            TargetSeq = couch_util:get_value(<<"seq">>, TProps, 0),
  -            erlang:min(SourceSeq, TargetSeq)
  -        catch error:{not_found, _} ->
  -            0
  -        end;
  -    {not_found, _} ->
  -        0
  -    end.
  -
  -
  -open_doc_revs(Db, #full_doc_info{id=Id, rev_tree=RevTree}, Revs) ->
  -    {FoundRevs, _} = couch_key_tree:get_key_leafs(RevTree, Revs),
  -    lists:map(fun({#leaf{deleted=IsDel, ptr=SummaryPtr}, FoundRevPath}) ->
  -                  couch_db:make_doc(Db, Id, IsDel, SummaryPtr, FoundRevPath)
  -    end, FoundRevs).
  +filter_doc(Filter, FullDocInfo) when is_function(Filter) ->
  +    try Filter(FullDocInfo) of
  +        discard -> discard;
  +        _ -> keep
  +    catch _:_ ->
  +        keep
  +    end;
  +filter_doc(_, _) ->
  +    keep.
   
   
   iso8601_timestamp() ->
  
positive.code:     end.
  
  
  repl(#db{name=DbName, seq_tree=Bt}=Db, #acc{localid=LocalId}=Acc0) ->
      erlang:put(io_priority, {internal_repl, DbName}),
      Seq = calculate_start_seq(Db, Acc0#acc.target, LocalId),
      Acc1 = Acc0#acc{source=Db, seq=Seq},
      Fun = fun ?MODULE:changes_enumerator/3,
      {ok, _, Acc2} = couch_btree:fold(Bt, Fun, Acc1, [{start_key, Seq + 1}]),
      {ok, #acc{seq = LastSeq}} = replicate_batch(Acc2),
      {ok, couch_db:count_changes_since(Db, LastSeq)}.
  
  
  make_local_id(#shard{}=Source, #shard{}=Target) ->
      make_local_id(Source, Target, undefined).
  
  
negative.code:     {Go, Acc1}.
  
  
  replicate_batch(#acc{target = #shard{node=Node, name=Name}} = Acc) ->
      case find_missing_revs(Acc) of
      [] ->
  