You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/07/31 16:56:14 UTC
[couchdb] 24/34: Fix revision tree extensions
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e5fefbe46738dcc8e6a5d2c8adb08a86f2b8f066
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Jul 12 09:37:10 2019 -0500
Fix revision tree extensions
Previously I was forgetting to keep the previous history around which
ended up limiting the revision depth to two.
---
src/fabric/src/fabric2_db.erl | 19 +++++++++++--------
src/fabric/src/fabric2_util.erl | 9 +++++++++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index 3ea30e7..43d555c 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -1098,16 +1098,19 @@ update_doc_interactive(Db, Doc0, Future, _Options) ->
end
end,
- % When recreating a deleted document we want to extend
- % the winning revision branch rather than create a
- % new branch. If we did not do this we could be
- % recreating into a state that previously existed.
Doc1 = case Winner of
#{deleted := true} when not Doc0#doc.deleted ->
- {WinnerRevPos, WinnerRev} = maps:get(rev_id, Winner),
- WinnerRevPath = maps:get(rev_path, Winner),
- Doc0#doc{revs = {WinnerRevPos, [WinnerRev | WinnerRevPath]}};
- _ ->
+ % When recreating a deleted document we want to extend
+ % the winning revision branch rather than create a
+ % new branch. If we did not do this we could be
+ % recreating into a state that previously existed.
+ Doc0#doc{revs = fabric2_util:revinfo_to_revs(Winner)};
+ #{} ->
+ % Otherwise we're extending the target's revision
+ % history with this update
+ Doc0#doc{revs = fabric2_util:revinfo_to_revs(Target)};
+ not_found ->
+ % Creating a new doc means our revs start empty
Doc0
end,
diff --git a/src/fabric/src/fabric2_util.erl b/src/fabric/src/fabric2_util.erl
index fb59d59..48bf7d1 100644
--- a/src/fabric/src/fabric2_util.erl
+++ b/src/fabric/src/fabric2_util.erl
@@ -14,6 +14,7 @@
-export([
+ revinfo_to_revs/1,
revinfo_to_path/1,
sort_revinfos/1,
@@ -37,6 +38,14 @@
-include_lib("couch/include/couch_db.hrl").
+revinfo_to_revs(RevInfo) ->
+ #{
+ rev_id := {RevPos, Rev},
+ rev_path := RevPath
+ } = RevInfo,
+ {RevPos, [Rev | RevPath]}.
+
+
revinfo_to_path(RevInfo) ->
#{
rev_id := {RevPos, Rev},