jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1104233 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
Date Tue, 17 May 2011 13:22:34 GMT
Author: stefan
Date: Tue May 17 13:22:34 2011
New Revision: 1104233

URL: http://svn.apache.org/viewvc?rev=1104233&view=rev
Log:
MicroKernel prototype (WIP)

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java?rev=1104233&r1=1104232&r2=1104233&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
Tue May 17 13:22:34 2011
@@ -184,7 +184,7 @@ public class CommitBuilder {
         String rootNodeId = null;
         for (String path : orderedPaths) {
             // persist node
-            String id = store.putNode(staged.get(path));
+                String id = store.putNode(staged.get(path));
             if (PathUtil.denotesRoot(path)) {
                 rootNodeId = id;
             } else {
@@ -202,13 +202,29 @@ public class CommitBuilder {
             if (!currentHead.equals(baseRevId)) {
                 // recursively merge root of currentHead with new root (rootNodeId)
 /*
-                Node base = rep.getNode(baseRevId, "/");
-                Node node1 = rep.getNode(currentHead, "/");
-                Node node2 = rep.getStore().getNode(rootNodeId);
-                NodeDelta delta1 = new NodeDelta(base, node1);
-                NodeDelta delta2 = new NodeDelta(base, node2);
-                if (!delta1.conflictsWith(delta2)) {
-                    // todo merge
+                Node baseNode = rep.getNode(baseRevId, "/");
+                Node theirNode = rep.getNode(currentHead, "/");
+                Node ourNode = rep.getStore().getNode(rootNodeId);
+                NodeDelta theirChanges = new NodeDelta(baseNode, theirNode);
+                NodeDelta ourChanges = new NodeDelta(baseNode, ourNode);
+                if (!theirChanges.conflictsWith(ourChanges)) {
+                    // merge
+                    MutableNode mergedNode = new MutableNode(theirNode);
+
+                    mergedNode.getProperties().putAll(ourChanges.getAddedProperties());
+                    mergedNode.getProperties().putAll(ourChanges.getChangedProperties());
+                    for (String name : ourChanges.getRemovedProperties().keySet()) {
+                        mergedNode.getProperties().remove(name);
+                    }
+
+                    mergedNode.getChildNodeEntries().putAll(ourChanges.getAddedChildNodes());
+                    mergedNode.getChildNodeEntries().putAll(ourChanges.getChangedChildNodes());
+                    for (String name : ourChanges.getRemovedChildNodes().keySet()) {
+                        mergedNode.getChildNodeEntries().remove(name);
+                    }
+                    // persist merged root node
+                    rootNodeId = store.putNode(mergedNode);
+                    baseRevId = currentHead;
                 } else {
                     // todo merge and/or traverse
                 }



Mime
View raw message