Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 64A4417614 for ; Fri, 31 Oct 2014 19:53:25 +0000 (UTC) Received: (qmail 9192 invoked by uid 500); 31 Oct 2014 19:53:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 9049 invoked by uid 500); 31 Oct 2014 19:53:25 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 8691 invoked by uid 99); 31 Oct 2014 19:53:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Oct 2014 19:53:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 845C7927B93; Fri, 31 Oct 2014 19:53:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bbastian@apache.org To: commits@couchdb.apache.org Date: Fri, 31 Oct 2014 19:53:30 -0000 Message-Id: <123b6aa6bcf04763b587bde481538a96@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/11] couch commit: updated refs/heads/master to 6125862 Add rev to view changes respose. See couch_mrview for corresponding changes Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/434b5414 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/434b5414 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/434b5414 Branch: refs/heads/master Commit: 434b5414ed975747e8144f9c5542cefa3f83fe3c Parents: 20e585d Author: Benjamin Bastian Authored: Mon Aug 25 16:50:05 2014 +0700 Committer: Benjamin Bastian Committed: Fri Oct 31 12:43:53 2014 -0700 ---------------------------------------------------------------------- src/couch_changes.erl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/434b5414/src/couch_changes.erl ---------------------------------------------------------------------- diff --git a/src/couch_changes.erl b/src/couch_changes.erl index 259f83c..50f9d50 100644 --- a/src/couch_changes.erl +++ b/src/couch_changes.erl @@ -265,7 +265,7 @@ filter(Db, DocInfo, {custom, Style, Req0, DDoc, FName}) -> {ok, Passes} = couch_query_servers:filter_docs(Req, Db, DDoc, FName, Docs), filter_revs(Passes, Docs). -fast_view_filter(Db, {{Seq, _}, {ID, _}}, {fast_view, Style, _, _}) -> +fast_view_filter(Db, {{Seq, _}, {ID, _, _}}, {fast_view, Style, _, _}) -> case couch_db:get_doc_info(Db, ID) of {ok, #doc_info{high_seq=Seq}=DocInfo} -> Docs = open_revs(Db, DocInfo, Style), @@ -284,15 +284,15 @@ fast_view_filter(Db, {{Seq, _}, {ID, _}}, {fast_view, Style, _, _}) -> % I left the Seq > HighSeq guard in so if (for some godforsaken % reason) the seq in the view is more current than the database, % we'll throw an error. - {ok, []}; + {undefined, []}; {error, not_found} -> - {ok, []} + {undefined, []} end. -view_filter(_Db, _KV, {default, _Style}) -> - [ok]. % TODO: make a real thing +view_filter(Db, KV, {default, Style}) -> + apply_view_style(Db, KV, Style). get_view_qs({json_req, {Props}}) -> @@ -353,6 +353,16 @@ apply_style(#doc_info{revs=Revs}, main_only) -> apply_style(#doc_info{revs=Revs}, all_docs) -> [{[{<<"rev">>, couch_doc:rev_to_str(R)}]} || #rev_info{rev=R} <- Revs]. +apply_view_style(_Db, {{_Seq, _Key}, {_ID, _Value, Rev}}, main_only) -> + [{[{<<"rev">>, couch_doc:rev_to_str(Rev)}]}]; +apply_view_style(Db, {{_Seq, _Key}, {ID, _Value, _Rev}}, all_docs) -> + case couch_db:get_doc_info(Db, ID) of + {ok, DocInfo} -> + apply_style(DocInfo, all_docs); + {error, not_found} -> + [] + end. + open_revs(Db, DocInfo, Style) -> DocInfos = case Style of @@ -627,7 +637,7 @@ changes_enumerator(Value0, Acc) -> changes_row(Results, DocInfo, #changes_acc{filter={fast_view,_,_,_}}=Acc) -> format_doc_info_change(Results, DocInfo, Acc); changes_row(Results, KV, #changes_acc{view=#mrview{}}) -> - {{Seq, Key}, {Id, Value}} = KV, + {{Seq, Key}, {Id, Value, _Rev}} = KV, {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key}, {<<"value">>, Value}, {<<"changes">>, Results}]}; changes_row(Results, #doc_info{}=DocInfo, Acc) -> format_doc_info_change(Results, DocInfo, Acc).