You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2020/02/19 05:40:57 UTC

[couchdb] branch fdb_to_revinfo-compatibility updated (fbae936 -> eb9f92d)

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

jaydoane pushed a change to branch fdb_to_revinfo-compatibility
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard fbae936  Add fdb_to_revinfo compatibility with 5-tuple Val
     new eb9f92d  Add fdb_to_revinfo compatibility with 5-tuple Val

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   (fbae936)
            \
             N -- N -- N   refs/heads/fdb_to_revinfo-compatibility (eb9f92d)

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/fabric/test/fabric2_db_misc_tests.erl | 1 -
 1 file changed, 1 deletion(-)


[couchdb] 01/01: Add fdb_to_revinfo compatibility with 5-tuple Val

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

jaydoane pushed a commit to branch fdb_to_revinfo-compatibility
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit eb9f92ddefe7f362adad70e3ff001a3a583403b5
Author: Jay Doane <ja...@apache.org>
AuthorDate: Tue Feb 18 21:40:32 2020 -0800

    Add fdb_to_revinfo compatibility with 5-tuple Val
    
    Currently, a 5-tuple `Val` parameter crashes fdb_to_revinfo with a
    function_clause error.
    
    This adds a compatible function clause, and also a catchall clause to
    log an error and throw an informative exception.
---
 src/fabric/src/fabric2_fdb.erl            | 26 +++++++++++++++++++++-
 src/fabric/test/fabric2_db_misc_tests.erl | 37 +++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/src/fabric/src/fabric2_fdb.erl b/src/fabric/src/fabric2_fdb.erl
index e51b8de..c181225 100644
--- a/src/fabric/src/fabric2_fdb.erl
+++ b/src/fabric/src/fabric2_fdb.erl
@@ -38,6 +38,8 @@
     incr_stat/3,
     incr_stat/4,
 
+    fdb_to_revinfo/2,
+
     get_all_revs/2,
     get_winning_revs/3,
     get_winning_revs_future/3,
@@ -1253,6 +1255,21 @@ fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _, _, _} = Val) ->
         rev_size => RevSize
     };
 
+fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _, _} = Val) ->
+    {?DB_REVS, _DocId, NotDeleted, RevPos, Rev} = Key,
+    {_RevFormat, Sequence, RevSize, RevPath, AttHash} = Val,
+    #{
+        winner => true,
+        exists => true,
+        deleted => not NotDeleted,
+        rev_id => {RevPos, Rev},
+        rev_path => tuple_to_list(RevPath),
+        sequence => Sequence,
+        branch_count => undefined,
+        att_hash => AttHash,
+        rev_size => RevSize
+    };
+
 fdb_to_revinfo(Key, {?CURR_REV_FORMAT, _, _, _} = Val)  ->
     {?DB_REVS, _DocId, NotDeleted, RevPos, Rev} = Key,
     {_RevFormat, RevPath, AttHash, RevSize} = Val,
@@ -1282,7 +1299,14 @@ fdb_to_revinfo(Key, {1, Seq, BCount, RPath, AttHash}) ->
 
 fdb_to_revinfo(Key, {1, RPath, AttHash}) ->
     Val = {?CURR_REV_FORMAT, RPath, AttHash, 0},
-    fdb_to_revinfo(Key, Val).
+    fdb_to_revinfo(Key, Val);
+
+fdb_to_revinfo(Key, Val) ->
+    couch_log:error(
+        "~p:fdb_to_revinfo unsupported val format "
+        "rev_format=~p key_size=~p val_size=~p",
+        [?MODULE, element(1, Val), tuple_size(Key), tuple_size(Val)]),
+    throw({unsupported_data_format, fdb_to_revinfo_val}).
 
 
 doc_to_fdb(Db, #doc{} = Doc) ->
diff --git a/src/fabric/test/fabric2_db_misc_tests.erl b/src/fabric/test/fabric2_db_misc_tests.erl
index c48ee2c..6d19f1c 100644
--- a/src/fabric/test/fabric2_db_misc_tests.erl
+++ b/src/fabric/test/fabric2_db_misc_tests.erl
@@ -325,3 +325,40 @@ db_version_bump({DbName, _, _}) ->
 
     % Check that db handle in the cache got the new metadata version
     ?assertMatch(#{db_version := NewDbVersion}, Db2).
+
+
+fdb_to_revinfo_test_() ->
+    {
+        "Test fdb_to_revinfo compatibility",
+        {
+            setup,
+            fun() -> ok end,
+            fun(_) -> ok end,
+            with([
+                ?TDEF(fdb_to_revinfo)
+            ])
+        }
+    }.
+
+
+fdb_to_revinfo(_) ->
+    Sequence = {versionstamp, 10873034897377, 0, 0},
+    Rev = <<60,84,174,140,210,120,192,18,100,148,9,181,129,165,248,92>>,
+    Key = {20, <<"d491280e-feab-42ce-909e-a7287d7b078-bluemix">>, true, 1, Rev},
+    FiveTupleVal = {2, Sequence, 1, {}, <<>>},
+    Expect = #{
+        att_hash => <<>>,
+        branch_count => undefined,
+        deleted => false,
+        exists => true,
+        rev_id =>
+            {1, <<60,84,174,140,210,120,192,18,100,148,9,181,129,165,248,92>>},
+        rev_path => [],
+        rev_size => 1,
+        sequence => Sequence,
+        winner => true
+    },
+    ?assertEqual(Expect, fabric2_fdb:fdb_to_revinfo(Key, FiveTupleVal)),
+    ?assertThrow({unsupported_data_format, fdb_to_revinfo_val},
+        fabric2_fdb:fdb_to_revinfo({bad}, {input})),
+    ok.