This is an automated email from the ASF dual-hosted git repository.

jiahuili430 pushed a commit to branch fix-changes-stats
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f79edb8a70981fd89824e171c734124497287703
Author: Jiahui Li <lijiahui...@gmail.com>
AuthorDate: Fri Jan 5 10:23:18 2024 -0600

    Remove deleted revs from `_conflicts` field
---
 src/chttpd/test/eunit/chttpd_changes_test.erl | 6 +++---
 src/couch/src/couch_changes.erl               | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/chttpd/test/eunit/chttpd_changes_test.erl 
b/src/chttpd/test/eunit/chttpd_changes_test.erl
index d2375cde8..ef26a52ee 100644
--- a/src/chttpd/test/eunit/chttpd_changes_test.erl
+++ b/src/chttpd/test/eunit/chttpd_changes_test.erl
@@ -873,7 +873,7 @@ t_selector_open_doc_times({_, DbUrl}) ->
     Filter = called_times(fun() -> changes_post(DbUrl, Body, F) end, DbUrl),
     FilterDocs = called_times(fun() -> changes_post(DbUrl, Body, F ++ I) end, 
DbUrl),
     FilterAllDocs = called_times(fun() -> changes_post(DbUrl, Body, F ++ I ++ 
S) end, DbUrl),
-    ?assertEqual({3, 4, 6}, {Filter, FilterDocs, FilterAllDocs}).
+    ?assertEqual({3, 3, 5}, {Filter, FilterDocs, FilterAllDocs}).
 
 t_js_filter_open_doc_times({_, DbUrl}) ->
     {DDocUrl, Rev} = create_ddocs(DbUrl, ?DOC1, custom),
@@ -883,7 +883,7 @@ t_js_filter_open_doc_times({_, DbUrl}) ->
     Filter = called_times(fun() -> changes(DbUrl, F) end, DbUrl),
     FilterDocs = called_times(fun() -> changes(DbUrl, F ++ I) end, DbUrl),
     FilterAllDocs = called_times(fun() -> changes(DbUrl, F ++ I ++ S) end, 
DbUrl),
-    ?assertEqual({4, 5, 7}, {Filter, FilterDocs, FilterAllDocs}),
+    ?assertEqual({4, 4, 6}, {Filter, FilterDocs, FilterAllDocs}),
     delete_ddocs(DDocUrl, Rev).
 
 t_view_open_doc_times({_, DbUrl}) ->
@@ -894,7 +894,7 @@ t_view_open_doc_times({_, DbUrl}) ->
     Filter = called_times(fun() -> changes(DbUrl, F) end, DbUrl),
     FilterDocs = called_times(fun() -> changes(DbUrl, F ++ I) end, DbUrl),
     FilterAllDocs = called_times(fun() -> changes(DbUrl, F ++ S ++ I) end, 
DbUrl),
-    ?assertEqual({4, 5, 7}, {Filter, FilterDocs, FilterAllDocs}),
+    ?assertEqual({4, 4, 6}, {Filter, FilterDocs, FilterAllDocs}),
     delete_ddocs(DDocUrl, Rev).
 
 % Utility functions
diff --git a/src/couch/src/couch_changes.erl b/src/couch/src/couch_changes.erl
index 59a1883c8..5114cb0a1 100644
--- a/src/couch/src/couch_changes.erl
+++ b/src/couch/src/couch_changes.erl
@@ -401,7 +401,7 @@ open_all_revs_include_doc(Db, DocInfo) ->
     OpenResults = [couch_db:open_doc(Db, DI, OpenOpts) || DI <- DocInfos],
     Docs = [Doc || {ok, Doc} <- OpenResults],
     [Doc1 | RestDocs] = Docs,
-    RestRevs = [Doc#doc.revs || Doc <- RestDocs],
+    RestRevs = [Doc#doc.revs || Doc <- RestDocs, Doc#doc.deleted =:= false],
     Conflicts = [{conflicts, [{Pos, RevId} || {Pos, [RevId]} <- RestRevs]}],
     Doc2 = Doc1#doc{meta = Conflicts},
     {[Doc2], Docs}.

Reply via email to