You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2023/05/07 17:37:12 UTC

[couchdb] branch dry-etag-generation updated (3deee947c -> 98eb4ef96)

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

vatamane pushed a change to branch dry-etag-generation
in repository https://gitbox.apache.org/repos/asf/couchdb.git


 discard 3deee947c Remove duplicate etag generation function
     new 98eb4ef96 Remove duplicate etag generation function

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (3deee947c)
            \
             N -- N -- N   refs/heads/dry-etag-generation (98eb4ef96)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch/test/eunit/couch_etag_tests.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


[couchdb] 01/01: Remove duplicate etag generation function

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch dry-etag-generation
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 98eb4ef969bb8667627ac461c89dbe04b2fd77f9
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Sun May 7 13:08:47 2023 -0400

    Remove duplicate etag generation function
    
    Use the couch_httpd one as it would be odd for couch_httpd to call chttpd.
    
    Also fix the test assertion order: the first argument should be the expected
    value, the second one should be the test value [1]
    
    [1] https://www.erlang.org/doc/apps/eunit/chapter.html#Assert_macros
---
 src/chttpd/src/chttpd.erl                 | 3 +--
 src/couch/src/couch_httpd.erl             | 4 ++--
 src/couch/test/eunit/couch_etag_tests.erl | 4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index ee1219511..689af7cef 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -813,8 +813,7 @@ doc_etag(#doc{id = Id, body = Body, revs = {Start, [DiskRev | _]}}) ->
     couch_httpd:doc_etag(Id, Body, {Start, DiskRev}).
 
 make_etag(Term) ->
-    <<SigInt:128/integer>> = exxhash:xxhash128(term_to_binary(Term)),
-    list_to_binary(io_lib:format("\"~.36B\"", [SigInt])).
+    couch_httpd:make_etag(Term).
 
 etag_match(Req, CurrentEtag) when is_binary(CurrentEtag) ->
     etag_match(Req, binary_to_list(CurrentEtag));
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index 76f8279f6..839404798 100644
--- a/src/couch/src/couch_httpd.erl
+++ b/src/couch/src/couch_httpd.erl
@@ -745,8 +745,8 @@ rev_etag({Start, DiskRev}) ->
     <<$", Rev/binary, $">>.
 
 make_etag(Term) ->
-    <<SigInt:128/integer>> = couch_hash:md5_hash(term_to_binary(Term)),
-    iolist_to_binary([$", io_lib:format("~.36B", [SigInt]), $"]).
+    <<SigInt:128/integer>> = exxhash:xxhash128(term_to_binary(Term)),
+    list_to_binary(io_lib:format("\"~.36B\"", [SigInt])).
 
 etag_match(Req, CurrentEtag) when is_binary(CurrentEtag) ->
     etag_match(Req, binary_to_list(CurrentEtag));
diff --git a/src/couch/test/eunit/couch_etag_tests.erl b/src/couch/test/eunit/couch_etag_tests.erl
index 72db6008a..54e677631 100644
--- a/src/couch/test/eunit/couch_etag_tests.erl
+++ b/src/couch/test/eunit/couch_etag_tests.erl
@@ -16,12 +16,12 @@
 
 local_with_empty_body_test() ->
     Etag = couch_httpd:doc_etag(<<"_local/local-and-empty">>, {[]}, {0, <<"1">>}),
-    ?assertEqual(Etag, <<"\"5ZVXQYO7VLEOU0TL9VXDNP5PV\"">>).
+    ?assertEqual(<<"\"A4Q262OE0BOPODSYG6Z2A449\"">>, Etag).
 
 local_with_body_test() ->
     DocBody = {[{<<"hello">>, <<"world">>}, {<<"relax">>, true}]},
     Etag = couch_httpd:doc_etag(<<"_local/local-with-body">>, DocBody, {0, <<"1">>}),
-    ?assertEqual(Etag, <<"\"CEFXP6WH8OKYIWO1GLGBHKCCA\"">>).
+    ?assertEqual(<<"\"266X8HX6TVMBGQBJAGSY0JON\"">>, Etag).
 
 normal_doc_uses_rev_test() ->
     DocBody = {[{<<"hello">>, <<"world">>}, {<<"relax">>, true}]},