jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1328397 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/mk/simple/ oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/ oak-mk/src/main/java/org/apache/jackrabbit/mk/core/ oak-mk/src/main/java/org/apache/jackrabb...
Date Fri, 20 Apr 2012 15:18:20 GMT
Author: stefan
Date: Fri Apr 20 15:18:19 2012
New Revision: 1328397

URL: http://svn.apache.org/viewvc?rev=1328397&view=rev
Log:
 OAK-45: Add support for branching and merging of private copies to MicroKernel 
 
 - added basic test case for branch & merge 
 - fixed a bug in StoredCommit which caused getJournal to fail
 - integration tests currently fail with UnsupportedOperationException when using the non-default
mk impl in oak-core

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java?rev=1328397&r1=1328396&r2=1328397&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
Fri Apr 20 15:18:19 2012
@@ -130,6 +130,8 @@ public class SimpleKernelImpl extends Mi
     }
 
     public synchronized String commitStream(String rootPath, JsopReader jsonDiff, String
revisionId, String message) {
+        revisionId = revisionId == null ? headRevision : revisionId;
+
         // TODO message should be json
         // TODO read / write version
         // TODO getJournal and getRevision don't have a path,
@@ -380,6 +382,9 @@ public class SimpleKernelImpl extends Mi
     }
 
     public JsopReader getJournalStream(String fromRevisionId, String toRevisionId, String
filter) {
+        fromRevisionId = fromRevisionId == null ? headRevision : fromRevisionId;
+        toRevisionId = toRevisionId == null ? headRevision : toRevisionId;
+
         long fromRev = Revision.parseId(fromRevisionId);
         long toRev = Revision.parseId(toRevisionId);
         NodeImpl node = getRoot();
@@ -444,6 +449,8 @@ public class SimpleKernelImpl extends Mi
 
 
     public JsopReader diffStream(String fromRevisionId, String toRevisionId, String filter)
{
+        fromRevisionId = fromRevisionId == null ? headRevision : fromRevisionId;
+        toRevisionId = toRevisionId == null ? headRevision : toRevisionId;
         // TODO implement if required
         return new JsopStream();
     }
@@ -463,6 +470,8 @@ public class SimpleKernelImpl extends Mi
     }
 
     public JsopReader getNodesStream(String path, String revisionId, int depth, long offset,
int count, String filter) {
+        revisionId = revisionId == null ? headRevision : revisionId;
+
         // TODO offset > 0 should mean the properties are not included
         if (count < 0) {
             count = nodeMap.getMaxMemoryChildren();
@@ -520,6 +529,8 @@ public class SimpleKernelImpl extends Mi
     }
 
     public boolean nodeExists(String path, String revisionId) {
+        revisionId = revisionId == null ? headRevision : revisionId;
+
         if (!PathUtils.isAbsolute(path)) {
             throw ExceptionFactory.get("Not an absolute path: " + path);
         }
@@ -532,6 +543,8 @@ public class SimpleKernelImpl extends Mi
     }
 
     public long getChildNodeCount(String path, String revisionId) {
+        revisionId = revisionId == null ? headRevision : revisionId;
+
         if (!PathUtils.isAbsolute(path)) {
             throw ExceptionFactory.get("Not an absolute path: " + path);
         }
@@ -569,6 +582,8 @@ public class SimpleKernelImpl extends Mi
     }
 
     public String branch(String trunkRevisionId) throws MicroKernelException {
+        trunkRevisionId = trunkRevisionId == null ? headRevision : trunkRevisionId;
+
         // TODO OAK-45 support
         throw new UnsupportedOperationException();
     }

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?rev=1328397&r1=1328396&r2=1328397&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
Fri Apr 20 15:18:19 2012
@@ -284,4 +284,39 @@ public class MicroKernelIT extends Abstr
         String json = mk.getNodes('/' + node, head);
         assertEquals("{\":childNodeCount\":0}", json);
     }
+
+    @Test
+    public void branchAndMerge() {
+        // make sure /branch doesn't exist in head
+        assertFalse(mk.nodeExists("/branch", null));
+
+        // create a branch on head
+        String branchRev = mk.branch(null);
+
+        // add a node /branch in branchRev
+        branchRev = mk.commit("", "+\"/branch\":{}", branchRev, "");
+        // make sure /branch doesn't exist in head
+        assertFalse(mk.nodeExists("/branch", null));
+        // make sure /branch does exist in branchRev
+        assertTrue(mk.nodeExists("/branch", branchRev));
+
+        // add a node /branch/foo in branchRev
+        branchRev = mk.commit("", "+\"/branch/foo\":{}", branchRev, "");
+
+        String hist = mk.getRevisionHistory(0, -1);
+        // make sure branchRev doesn't show up in revision history
+        assertFalse(hist.contains(branchRev));
+
+        // add a node /test123 in head
+        mk.commit("", "+\"/test123\":{}", null, "");
+        // make sure /test123 doesn't exist in branchRev
+        assertFalse(mk.nodeExists("/test123", branchRev));
+
+        // merge branchRev with head
+        mk.merge(branchRev, "");
+        // make sure /test123 still exists in head
+        assertTrue(mk.nodeExists("/test123", null));
+        // make sure /branch/foo does now exist in head
+        assertTrue(mk.nodeExists("/branch/foo", null));
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java?rev=1328397&r1=1328396&r2=1328397&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
Fri Apr 20 15:18:19 2012
@@ -187,12 +187,12 @@ public class MicroKernelImpl implements 
                 }
                 Id commitId = commit.getParentId();
                 if (commitId == null) {
-                    // shouldn't get here, ignore
+                    // inconsistent revision history, ignore silently...
                     break;
                 }
                 commit = rep.getCommit(commitId);
                 if (commit.getCommitTS() < fromCommit.getCommitTS()) {
-                    // shouldn't get here, ignore
+                    // inconsistent revision history, ignore silently...
                     break;
                 }
             }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java?rev=1328397&r1=1328396&r2=1328397&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
Fri Apr 20 15:18:19 2012
@@ -34,7 +34,7 @@ public class StoredCommit extends Abstra
         String branchRootId = binding.readStringValue("branchRootId");
         return new StoredCommit(id, "".equals(parentId) ? null : Id.fromString(parentId),
                 commitTS, rootNodeId, "".equals(msg) ? null : msg, changes,
-                "".equals(parentId) ? null : Id.fromString(branchRootId));
+                "".equals(branchRootId) ? null : Id.fromString(branchRootId));
     }
 
     public StoredCommit(Id id, Id parentId, long commitTS, Id rootNodeId, String msg, String
changes, Id branchRootId) {



Mime
View raw message