Author: mreutegg Date: Thu May 15 07:29:11 2014 New Revision: 1594799 URL: http://svn.apache.org/r1594799 Log: OAK-1820: Set _lastRev on insert when new node is also commit root
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1594799&r1=1594798&r2=1594799&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java Thu May 15 07:29:11 2014 @@ -312,6 +312,7 @@ public class Commit { // it is the root of a subtree added in a commit. // so we try to add the root like all other nodes NodeDocument.setRevision(commitRoot, revision, commitValue); + NodeDocument.setLastRev(commitRoot, revision); newNodes.add(commitRoot); } try { Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1594799&r1=1594798&r2=1594799&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (original) +++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Thu May 15 07:29:11 2014 @@ -391,6 +391,28 @@ public class DocumentNodeStoreTest { nodeStore3.dispose(); } + // OAK-1820 + @Test + public void setLastRevOnCommitForNewNode() throws Exception { + DocumentNodeStore ns = new DocumentMK.Builder() + .setAsyncDelay(0).getNodeStore(); + // add a first child node. this will set the children flag on root + // and move the commit root to the root + NodeBuilder builder = ns.getRoot().builder(); + builder.child("foo"); + ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); + + // the second time, the added node is also the commit root, this + // is the case we are interested in + builder = ns.getRoot().builder(); + builder.child("bar"); + ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); + + NodeDocument doc = ns.getDocumentStore().find(NODES, + Utils.getIdFromPath("/bar")); + assertEquals(1, doc.getLastRev().size()); + } + private static class TestHook extends EditorHook { TestHook(final String prefix) {