summaryrefslogtreecommitdiff
path: root/src/fabric_rpc.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-05-28 13:15:38 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-05-28 13:18:57 -0400
commit450bc69ea891d9ad03c26c31c181c28ee5cbe8f9 (patch)
treec0a1b4db1fbd6354ef5c22eb832aad3f623d6962 /src/fabric_rpc.erl
parent8dc112522f8baef4454f3c0ca74fbbd920fc451d (diff)
implement fabric missing_revs, BugzID 10217
Diffstat (limited to 'src/fabric_rpc.erl')
-rw-r--r--src/fabric_rpc.erl23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index c54ec247..75ce5e90 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -1,12 +1,31 @@
-module(fabric_rpc).
--export([open_doc/3, open_doc/4, get_db_info/1, update_docs/3]).
+-export([open_doc/3, open_doc/4, get_db_info/1, update_docs/3,
+ get_missing_revs/2]).
+-include("../../couch/src/couch_db.hrl").
-include_lib("eunit/include/eunit.hrl").
+
open_doc(DbName, DocId, Options) ->
- io:format("~p ~p ~p ~p~n", [?MODULE, DbName, DocId, Options]),
with_db(DbName, {couch_db, open_doc_int, [DocId, Options]}).
+get_missing_revs(DbName, IdRevsList) ->
+ % reimplement here so we get [] for Ids with no missing revs in response
+ rexi:reply(case couch_db:open(DbName, []) of
+ {ok, Db} ->
+ Ids = [Id1 || {Id1, _Revs} <- IdRevsList],
+ {ok, lists:zipwith(fun({Id, Revs}, FullDocInfoResult) ->
+ case FullDocInfoResult of
+ {ok, #full_doc_info{rev_tree=RevisionTree}} ->
+ {Id, couch_key_tree:find_missing(RevisionTree, Revs)};
+ not_found ->
+ {Id, Revs}
+ end
+ end, IdRevsList, couch_btree:lookup(Db#db.id_tree, Ids))};
+ Error ->
+ Error
+ end).
+
%% rpc endpoints
%% call to with_db will supply your M:F with a #db{} and then remaining args