Amend a too-restrictive pattern match We were asserting that the subpath contains exactly one element, but in reality the subpath can be empty (which will result in an immediate failure to merge on the next recursion).
BugzID: 30686 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/50b5aab1 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/50b5aab1 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/50b5aab1 Branch: refs/heads/windsor-merge Commit: 50b5aab12bdbd4a54d2fc530330e062d08c7f1c5 Parents: e32f166 Author: Adam Kocoloski <[email protected]> Authored: Wed May 7 11:27:47 2014 -0400 Committer: Robert Newson <[email protected]> Committed: Tue Aug 26 10:42:38 2014 +0100 ---------------------------------------------------------------------- src/couch_key_tree.erl | 4 ++++ 1 file changed, 4 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/50b5aab1/src/couch_key_tree.erl ---------------------------------------------------------------------- diff --git a/src/couch_key_tree.erl b/src/couch_key_tree.erl index 57c08a0..8007e17 100644 --- a/src/couch_key_tree.erl +++ b/src/couch_key_tree.erl @@ -139,6 +139,10 @@ merge_at(Nodes, Pos, [{IK, IV, [NextINode]}]) when Pos > 0 -> {Merged, Result} -> {[{IK, IV, Merged}], Result}; fail -> fail end; +merge_at(_Nodes, Pos, [{_IK, _IV, []}]) when Pos > 0 -> + % We've run out of path on the insert side, there's no way we can + % merge with this branch + fail; merge_at([{K, V, SubTree} | Sibs], Pos, INodes) when Pos < 0 -> % When Pos is negative, Depth was less than IDepth, so we % need to discard from the revision tree path
