jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1420717 - in /jackrabbit/oak/trunk: oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/ oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/ oak-mk/src/main/java/org/apache/jackrabbit/mk/core/
Date Wed, 12 Dec 2012 14:54:17 GMT
Author: stefan
Date: Wed Dec 12 14:54:16 2012
New Revision: 1420717

URL: http://svn.apache.org/viewvc?rev=1420717&view=rev
Log:
OAK-501: Add journal support for branches

Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
    jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java

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=1420717&r1=1420716&r2=1420717&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
Wed Dec 12 14:54:16 2012
@@ -1004,6 +1004,8 @@ public class MicroKernelIT extends Abstr
         // make sure /branch doesn't exist in head
         assertFalse(mk.nodeExists("/branch", null));
 
+        String oldHead = mk.getHeadRevision();
+
         // create a branch on head
         String branchRev = mk.branch(null);
         String branchRootRev = branchRev;
@@ -1040,16 +1042,20 @@ public class MicroKernelIT extends Abstr
         assertTrue(mk.nodeExists("/branch/foo", null));
 
         try {
+            mk.getJournal(oldHead, branchRev, "/");
+        } catch (MicroKernelException e) {
+            fail("getJournal should succeed if the range spans from a (older) head to a (newer)
private branch revision");
+        }
+        try {
             mk.getJournal(branchRootRev, null, "/");
-            fail("getJournal should throw for branch revisions");
+            fail("getJournal should throw if the range spans from a (older) private branch
to a (newer) head revision");
         } catch (MicroKernelException e) {
             // expected
         }
         try {
             mk.getJournal(branchRootRev, branchRev, "/");
-            fail("getJournal should throw for branch revisions");
         } catch (MicroKernelException e) {
-            // expected
+            fail("getJournal should succeed if the range spans a single private branch");
         }
 
         String jrnl = mk.getJournal(newHead, newHead, "/");
@@ -1061,6 +1067,9 @@ public class MicroKernelIT extends Abstr
         // TODO properly verify json diff format
         // make sure json diff contains +"/branch":{...}
         assertTrue(diff.matches("\\s*\\+\\s*\"/branch\"\\s*:\\s*\\{\\s*\"foo\"\\s*:\\s*\\{\\s*\\}\\s*\\}\\s*"));
+
+        jrnl = mk.getJournal(oldHead, branchRev, "/");
+        array = parseJSONArray(jrnl);
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1420717&r1=1420716&r2=1420717&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
(original)
+++ jackrabbit/oak/trunk/oak-mk-api/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
Wed Dec 12 14:54:16 2012
@@ -166,8 +166,14 @@ public interface MicroKernel {
      * at {@code path}.
      * <p/>
      * A {@code MicroKernelException} is thrown if either {@code fromRevisionId}
-     * or {@code toRevisionId}  doesn't exist, denotes a <i>private</i> branch
-     * revision or if another error occurs.
+     * or {@code toRevisionId} doesn't exist, if {@code fromRevisionId} denotes
+     * a <i>private</i> branch revision <i>and</i> {@code toRevisionId}
denotes
+     * either a head revision or a revision on a different <i>private</i> branch,
+     * or if another error occurs.
+     * <p/>
+     * If the journal includes <i>private</i> branch revisions, those entries
+     * will include a {@code "branchRootId"} denoting the head revision the
+     * <i>private</i> branch is based on.
      *
      * @param fromRevisionId id of first revision to be returned in journal
      * @param toRevisionId   id of last revision to be returned in journal,

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=1420717&r1=1420716&r2=1420717&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
Wed Dec 12 14:54:16 2012
@@ -195,22 +195,23 @@ public class MicroKernelImpl implements 
         List<StoredCommit> commits = new ArrayList<StoredCommit>();
         try {
             StoredCommit toCommit = rep.getCommit(toRevisionId);
-            if (toCommit.getBranchRootId() != null) {
-                throw new MicroKernelException("branch revisions are not supported: " + toRevisionId);
-            }
 
             Commit fromCommit;
             if (toRevisionId.equals(fromRevisionId)) {
                 fromCommit = toCommit;
             } else {
                 fromCommit = rep.getCommit(fromRevisionId);
-                if (fromCommit.getCommitTS() > toCommit.getCommitTS()) {
-                    // negative range, return empty journal
-                    return "[]";
-                }
             }
+
             if (fromCommit.getBranchRootId() != null) {
-                throw new MicroKernelException("branch revisions are not supported: " + fromRevisionId);
+                if (!fromCommit.getBranchRootId().equals(toCommit.getBranchRootId())) {
+                    throw new MicroKernelException("inconsistent range specified: fromRevision
denotes a private branch while toRevision denotes a head or another private branch");
+                }
+            }
+
+            if (fromCommit.getCommitTS() > toCommit.getCommitTS()) {
+                // negative range, return empty journal
+                return "[]";
             }
 
             // collect commits, starting with toRevisionId
@@ -265,8 +266,11 @@ public class MicroKernelImpl implements 
             commitBuff.object().
                     key("id").value(commit.getId().toString()).
                     key("ts").value(commit.getCommitTS()).
-                    key("msg").value(commit.getMsg()).
-                    key("changes").value(diff).endObject();
+                    key("msg").value(commit.getMsg());
+            if (commit.getBranchRootId() != null) {
+                commitBuff.key("branchRootId").value(commit.getBranchRootId().toString());
+            }
+            commitBuff.key("changes").value(diff).endObject();
         }
         return commitBuff.endArray().toString();
     }



Mime
View raw message