From oak-commits-return-2393-apmail-jackrabbit-oak-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Wed Dec 12 14:54:45 2012 Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A48F7D30F for ; Wed, 12 Dec 2012 14:54:45 +0000 (UTC) Received: (qmail 10081 invoked by uid 500); 12 Dec 2012 14:54:45 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 10029 invoked by uid 500); 12 Dec 2012 14:54:44 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 9986 invoked by uid 99); 12 Dec 2012 14:54:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2012 14:54:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Dec 2012 14:54:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BCDD7238890B; Wed, 12 Dec 2012 14:54:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: oak-commits@jackrabbit.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121212145418.BCDD7238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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}. *

* A {@code MicroKernelException} is thrown if either {@code fromRevisionId} - * or {@code toRevisionId} doesn't exist, denotes a private branch - * revision or if another error occurs. + * or {@code toRevisionId} doesn't exist, if {@code fromRevisionId} denotes + * a private branch revision and {@code toRevisionId} denotes + * either a head revision or a revision on a different private branch, + * or if another error occurs. + *

+ * If the journal includes private branch revisions, those entries + * will include a {@code "branchRootId"} denoting the head revision the + * private 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 commits = new ArrayList(); 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(); }