anchor.diff:      end.
   
   pull_rep(DbTarget, DbSource, SourceSeqNum) ->
  -    SaveDocsPid = spawn_link(fun() ->
  -            save_docs_loop(DbTarget, 0) end),
  -    OpenDocsPid = spawn_link(fun() ->
  -            open_doc_revs_loop(DbSource, SaveDocsPid, 0) end),
  -    OpenDocsPid ! got_it, % prime queue with got_it
  -    MissingRevsPid = spawn_link(fun() ->
  -            get_missing_revs_loop(DbTarget, OpenDocsPid, 0, 0) end),
  -    MissingRevsPid ! got_it, % prime queue with got_it
  -    self() ! got_it,
  -    {ok, NewSeq} = enum_docs_since(DbSource, SourceSeqNum,
  -        fun(SrcDocInfo, _, _) ->
  -            #doc_info{id=Id,
  -                rev=Rev,
  -                conflict_revs=Conflicts,
  -                deleted_conflict_revs=DelConflicts,
  -                update_seq=Seq} = SrcDocInfo,
  -            SrcRevs = [Rev | Conflicts] ++ DelConflicts,
  -            receive got_it -> ok end,
  -            MissingRevsPid !  {self(), Id, SrcRevs}, % send to the missing revs process
  -            {ok, Seq}
  -        end, SourceSeqNum),
  -    
  -    receive got_it -> ok end,
  -    
  -    MissingRevsPid ! {self(), shutdown},
  -    receive {done, MissingRevsPid, Stats1} -> ok end,
  -    
  -    OpenDocsPid ! {self(), shutdown},
  -    receive {done, OpenDocsPid, Stats2} -> ok end,
  -    
  -    SaveDocsPid ! {self(), shutdown},
  -    receive {done, SaveDocsPid, Stats3} -> ok end,
  -    
  -    {NewSeq, Stats1 ++ Stats2 ++ Stats3}.
  -
  -
  -get_missing_revs_loop(DbTarget, OpenDocsPid, RevsChecked, MissingFound) ->
  -    receive got_it -> ok end,
  -    receive
  -    {Src, Id, Revs} ->
  -        Src ! got_it,
  -
  -        MissingRevs =
  -        case get_missing_revs(DbTarget, [{Id, Revs}]) of
  -        {ok, [{Id, MissingRevs0}]} ->
  -            OpenDocsPid ! {self(), Id, MissingRevs0},
  -            MissingRevs0;
  -        {ok, []} ->
  -            % prime our message queue
  -            self() ! got_it,
  -            []
  -        end,
  -        get_missing_revs_loop(DbTarget, OpenDocsPid,
  -                RevsChecked + length(Revs),
  -                MissingFound + length(MissingRevs));
  -    {Src, shutdown} ->
  -        Src ! {done, self(), [{<<"missing_checked">>, RevsChecked},
  -                                 {<<"missing_found">>, MissingFound}]}
  -    end.
  -    
  -
  -open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead) ->
  -    receive got_it -> ok end,
  -    receive
  -    {Src, Id, MissingRevs} ->
  -        Src ! got_it,
  -        {ok, DocResults} = open_doc_revs(DbSource, Id, MissingRevs, [latest]),
  -        % only save successful reads
  -        Docs = [RevDoc || {ok, RevDoc} <- DocResults],
  -        SaveDocsPid ! {self(), docs, Docs},
  -        open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead + length(Docs));
  -    {Src, shutdown} ->
  -        Src ! {done, self(), [{<<"docs_read">>, DocsRead}]}
  -    end.
  -
  -
  -        
  -save_docs_loop(DbTarget, DocsWritten) ->
  -    receive
  -    {Src, docs, Docs} ->
  -        Src ! got_it,
  -        ok = update_docs(DbTarget, Docs, [], false),
  -        save_docs_loop(DbTarget, DocsWritten + length(Docs));
  -    {Src, shutdown} ->
  -        Src ! {done, self(), [{<<"docs_written">>, DocsWritten}]}
  -    end.
  -
  +    http:set_options([{max_pipeline_length, 101}, {pipeline_timeout, 5000}]),
  +    {ok, {NewSeq, Stats}} = 
  +        enum_docs_since(DbSource, DbTarget, SourceSeqNum, {SourceSeqNum, []}),
  +    http:set_options([{max_pipeline_length, 2}, {pipeline_timeout, 0}]),
  +    {NewSeq, Stats}.
   
   do_http_request(Url, Action, Headers) ->
       do_http_request(Url, Action, Headers, []).
  
positive.code:         ?JSON_DECODE(ResponseBody)
      end.
  
  enum_docs0(_InFun, [], Acc) ->
      Acc;
  enum_docs0(InFun, [DocInfo | Rest], Acc) ->
      case InFun(DocInfo, 0, Acc) of
      {ok, Acc2} -> enum_docs0(InFun, Rest, Acc2);
      {stop, Acc2} -> Acc2
      end.
  
  fix_url(UrlBin) ->
      Url = binary_to_list(UrlBin),
  
negative.code: close_db(Db)->
      couch_db:close(Db).
  
  get_doc_info_list(#http_db{uri=DbUrl, headers=Headers}, StartSeq) ->
      Url = DbUrl ++ "_all_docs_by_seq?count=100&startkey=" 
          ++ integer_to_list(StartSeq),
      {Results} = do_http_request(Url, get, Headers),
      lists:map(fun({RowInfoList}) ->
          {RowValueProps} = proplists:get_value(<<"value">>, RowInfoList),
          #doc_info{
  