summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/couchdb/couch_key_tree.erl2
-rwxr-xr-xtest/etap/060-kt-merging.t11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/couchdb/couch_key_tree.erl b/src/couchdb/couch_key_tree.erl
index 2e3b3e3c..09712adf 100644
--- a/src/couchdb/couch_key_tree.erl
+++ b/src/couchdb/couch_key_tree.erl
@@ -43,7 +43,7 @@ merge_one([{Start, Tree}|Rest], {StartInsert, TreeInsert}, Acc, HasConflicts) ->
case merge_at([Tree], StartInsert - Start, [TreeInsert]) of
{ok, [Merged], Conflicts} ->
MergedStart = lists:min([Start, StartInsert]),
- merge_one(Rest, {MergedStart, Merged}, Acc, Conflicts or HasConflicts);
+ {ok, Rest ++ [{MergedStart, Merged} | Acc], Conflicts or HasConflicts};
no ->
AccOut = [{Start, Tree} | Acc],
merge_one(Rest, {StartInsert, TreeInsert}, AccOut, HasConflicts)
diff --git a/test/etap/060-kt-merging.t b/test/etap/060-kt-merging.t
index 5a8571ac..971e49bf 100755
--- a/test/etap/060-kt-merging.t
+++ b/test/etap/060-kt-merging.t
@@ -15,7 +15,7 @@
main(_) ->
test_util:init_code_path(),
- etap:plan(12),
+ etap:plan(14),
case (catch test()) of
ok ->
etap:end_tests();
@@ -106,10 +106,13 @@ test() ->
"Merging should create conflicts."
),
+ {MultiPaths, NoConflicts} = couch_key_tree:merge(Expect1, TwoChild),
+ etap:is(NoConflicts, no_conflicts, "Merge should have no conflicts."),
+ etap:is(length(MultiPaths), 2, "Should have two paths before stemming."),
etap:is(
- {[TwoChild], no_conflicts},
- couch_key_tree:merge(Expect1, TwoChild),
- "Merge should have no conflicts."
+ couch_key_tree:stem(MultiPaths, 10),
+ [TwoChild],
+ "Stemming should collapse the paths."
),
ok.