jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1376578 - in /jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk: core/MicroKernelImpl.java model/AbstractCommit.java model/CommitBuilder.java store/DefaultRevisionStore.java store/RevisionStore.java
Date Thu, 23 Aug 2012 16:28:14 GMT
Author: stefan
Date: Thu Aug 23 16:28:14 2012
New Revision: 1376578

URL: http://svn.apache.org/viewvc?rev=1376578&view=rev
Log:
OAK-267: throw exception on attempt to make a branch revision head

Modified:
    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/AbstractCommit.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java

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=1376578&r1=1376577&r2=1376578&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
Thu Aug 23 16:28:14 2012
@@ -33,6 +33,8 @@ import org.apache.jackrabbit.mk.model.tr
 import org.apache.jackrabbit.mk.util.CommitGate;
 import org.apache.jackrabbit.mk.util.NameFilter;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -43,6 +45,8 @@ import java.util.List;
  */
 public class MicroKernelImpl implements MicroKernel {
 
+    private static final Logger LOG = LoggerFactory.getLogger(MicroKernelImpl.class);
+
     protected Repository rep;
     private final CommitGate gate = new CommitGate();
 
@@ -227,6 +231,9 @@ public class MicroKernelImpl implements 
                     break;
                 }
             }
+        } catch (MicroKernelException e) {
+            // re-throw
+            throw e;
         } catch (Exception e) {
             throw new MicroKernelException(e);
         }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java?rev=1376578&r1=1376577&r2=1376578&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
Thu Aug 23 16:28:14 2012
@@ -85,4 +85,18 @@ public abstract class AbstractCommit imp
         binding.write("parentId", parentId == null ? "" : parentId.toString());
         binding.write("branchRootId", branchRootId == null ? "" : branchRootId.toString());
     }
+
+    //-----------------------------------------------------< Object overrides >
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("rootNodeId: '").append(rootNodeId.toString()).append("', ");
+        sb.append("commitTS: ").append(commitTS).append(", ");
+        sb.append("msg: '").append(msg == null ? "" : msg).append("', ");
+        sb.append("changes: '").append(changes == null ? "" : changes).append("', ");
+        sb.append("parentId: '").append(parentId == null ? "" : parentId.toString()).append("',
");
+        sb.append("branchRootId: '").append(branchRootId == null ? "" : branchRootId.toString()).append("'");
+        return sb.toString();
+    }
 }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1376578&r1=1376577&r2=1376578&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Thu Aug 23 16:28:14 2012
@@ -22,6 +22,8 @@ import org.apache.jackrabbit.mk.model.tr
 import org.apache.jackrabbit.mk.store.NotFoundException;
 import org.apache.jackrabbit.mk.store.RevisionStore;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -31,6 +33,8 @@ import java.util.List;
  */
 public class CommitBuilder {
 
+    private static final Logger LOG = LoggerFactory.getLogger(CommitBuilder.class);
+
     /** revision changes are based upon */
     private Id baseRevId;
 
@@ -225,6 +229,11 @@ public class CommitBuilder {
                     store.getNodeState(store.getRootNode(currentHead)),
                     store.getNodeState(store.getNode(rootNodeId)),
                     "/", -1, store, "").build();
+            if (diff.isEmpty()) {
+                LOG.debug("merge of empty branch {} with differing content hashes encountered,
ignore and keep current head {}",
+                        baseRevId, currentHead);
+                return currentHead;
+            }
             newCommit.setChanges(diff);
             newCommit.setRootNodeId(rootNodeId);
             newCommit.setBranchRootId(null);

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java?rev=1376578&r1=1376577&r2=1376578&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/DefaultRevisionStore.java
Thu Aug 23 16:28:14 2012
@@ -306,6 +306,11 @@ public class DefaultRevisionStore extend
                     "putHeadCommit called without holding write lock.");
         }
 
+        if (commit.getBranchRootId() != null) {
+            // OAK-267
+            throw new IllegalStateException("private branch commit [" + commit + "] cannot
become HEAD");
+        }
+
         Id id = writeCommit(token, commit);
         setHeadCommitId(id);
         

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java?rev=1376578&r1=1376577&r2=1376578&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
Thu Aug 23 16:28:14 2012
@@ -49,7 +49,7 @@ public interface RevisionStore extends R
     /**
      * Lock the head. Must be called prior to putting a new head commit.
      * 
-     * @see #putHeadCommit(PutToken, MutableCommit, Id)
+     * @see #putHeadCommit(PutToken, MutableCommit, Id, Id)
      * @see #unlockHead()
      */
     void lockHead();



Mime
View raw message