jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1420924 - /jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java
Date Wed, 12 Dec 2012 19:30:12 GMT
Author: meteatamel
Date: Wed Dec 12 19:30:11 2012
New Revision: 1420924

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

Added journal support for branches for MongoMK

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java?rev=1420924&r1=1420923&r2=1420924&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/command/GetJournalCommand.java
Wed Dec 12 19:30:11 2012
@@ -54,22 +54,22 @@ public class GetJournalCommand extends B
         List<MongoCommit> commits = getCommits(fromRevision, toRevision);
 
         MongoCommit toCommit = extractCommit(commits, toRevision);
-        if (toCommit != null && toCommit.getBranchId() != null) {
-            throw new MicroKernelException("Branch revisions are not supported: " + toRevisionId);
-        }
-
         MongoCommit fromCommit;
         if (toRevision == fromRevision) {
             fromCommit = toCommit;
         } else {
             fromCommit = extractCommit(commits, fromRevision);
-            if (fromCommit == null || (fromCommit.getTimestamp() > toCommit.getTimestamp()))
{
-                // negative range, return empty journal
-                return "[]";
+        }
+
+        if (fromCommit != null && fromCommit.getBranchId() != null) {
+            if (!fromCommit.getBranchId().equals(toCommit.getBranchId())) {
+                throw new MicroKernelException("Inconsistent range specified: fromRevision
denotes a private branch while toRevision denotes a head or another private branch");
             }
         }
-        if (fromCommit.getBranchId() != null) {
-            throw new MicroKernelException("Branch revisions are not supported: " + fromRevisionId);
+
+        if (fromCommit != null && fromCommit.getTimestamp() > toCommit.getTimestamp())
{
+            // negative range, return empty journal
+            return "[]";
         }
 
         JsopBuilder commitBuff = new JsopBuilder().array();
@@ -94,8 +94,11 @@ public class GetJournalCommand extends B
             commitBuff.object()
             .key("id").value(MongoUtil.fromMongoRepresentation(commit.getRevisionId()))
             .key("ts").value(commit.getTimestamp())
-            .key("msg").value(commit.getMessage())
-            .key("changes").value(diff).endObject();
+            .key("msg").value(commit.getMessage());
+            if (commit.getBranchId() != null) {
+                commitBuff.key("branchRootId").value(commit.getBranchId().toString());
+            }
+            commitBuff.key("changes").value(diff).endObject();
         }
         return commitBuff.endArray().toString();
     }



Mime
View raw message