summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_rep_missing_revs.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-02-26 01:11:02 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-02-26 01:11:02 +0000
commit2bdd75901fba402068d08e316a3ac32249307e27 (patch)
tree6635fd73f4d3c299f19be391664d7c2b056263c2 /src/couchdb/couch_rep_missing_revs.erl
parent5fb1e46f115e91f2788d2ac8649106667952ddfe (diff)
fdmananas patch for filtered replication via COUCHDB-673
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@916518 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep_missing_revs.erl')
-rw-r--r--src/couchdb/couch_rep_missing_revs.erl20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/couchdb/couch_rep_missing_revs.erl b/src/couchdb/couch_rep_missing_revs.erl
index 5790dd71..7b4956e2 100644
--- a/src/couchdb/couch_rep_missing_revs.erl
+++ b/src/couchdb/couch_rep_missing_revs.erl
@@ -144,11 +144,15 @@ changes_loop(OurServer, SourceChangesServer, Target) ->
changes_loop(OurServer, SourceChangesServer, Target).
get_missing_revs(#http_db{}=Target, Changes) ->
- Transform = fun({[{<<"seq">>,_}, {<<"id">>,Id}, {<<"changes">>,C}]}) ->
- {Id, [couch_doc:rev_to_str(R) || {[{<<"rev">>, R}]} <- C]} end,
+ Transform = fun({Props}) ->
+ C = proplists:get_value(<<"changes">>, Props),
+ Id = proplists:get_value(<<"id">>, Props),
+ {Id, [R || {[{<<"rev">>, R}]} <- C]}
+ end,
IdRevsList = [Transform(Change) || Change <- Changes],
SeqDict = changes_dictionary(Changes),
- {[{<<"seq">>, HighSeq}, _, _]} = lists:last(Changes),
+ {LastProps} = lists:last(Changes),
+ HighSeq = proplists:get_value(<<"seq">>, LastProps),
Request = Target#http_db{
resource = "_missing_revs",
method = post,
@@ -165,11 +169,15 @@ get_missing_revs(#http_db{}=Target, Changes) ->
end;
get_missing_revs(Target, Changes) ->
- Transform = fun({[{<<"seq">>,_}, {<<"id">>,Id}, {<<"changes">>,C}]}) ->
- {Id, [R || {[{<<"rev">>, R}]} <- C]} end,
+ Transform = fun({Props}) ->
+ C = proplists:get_value(<<"changes">>, Props),
+ Id = proplists:get_value(<<"id">>, Props),
+ {Id, [couch_doc:parse_rev(R) || {[{<<"rev">>, R}]} <- C]}
+ end,
IdRevsList = [Transform(Change) || Change <- Changes],
SeqDict = changes_dictionary(Changes),
- {[{<<"seq">>, HighSeq}, _, _]} = lists:last(Changes),
+ {LastProps} = lists:last(Changes),
+ HighSeq = proplists:get_value(<<"seq">>, LastProps),
{ok, Results} = couch_db:get_missing_revs(Target, IdRevsList),
{HighSeq, [{Id, dict:fetch(Id, SeqDict), Revs} || {Id, Revs, _} <- Results]}.