jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1402529 - in /jackrabbit/oak/trunk: oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.java
Date Fri, 26 Oct 2012 14:37:07 GMT
Author: stefan
Date: Fri Oct 26 14:37:06 2012
New Revision: 1402529

URL: http://svn.apache.org/viewvc?rev=1402529&view=rev
Log:
OAK-407: potential lost update on merge

Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.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=1402529&r1=1402528&r2=1402529&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
Fri Oct 26 14:37:06 2012
@@ -1025,6 +1025,36 @@ public class MicroKernelIT extends Abstr
     }
 
     @Test
+    public void branchAndMerge2() {
+        // make sure /trunk doesn't exist in head
+        assertFalse(mk.nodeExists("/trunk", null));
+
+        // add a node /trunk in head
+        mk.commit("", "+\"/trunk\":{}", null, "");
+        // add a node /trunk/child1 in head
+        mk.commit("", "+\"/trunk/child1\":{}", null, "");
+
+        // create a branch on head
+        String branchRev = mk.branch(null);
+        // add a node /trunk/child1/child2 in branchRev
+        branchRev = mk.commit("", "+\"/trunk/child1/child2\":{}", branchRev, "");
+
+        // add a node /trunk/child3 in head
+        mk.commit("", "+\"/trunk/child3\":{}", null, "");
+
+        // merge branchRev with head
+        mk.merge(branchRev, "");
+
+        assertTrue(mk.nodeExists("/trunk", null));
+        assertTrue(mk.nodeExists("/trunk/child1", null));
+
+        // make sure /trunk/child1/child2 does now exist in head
+        assertTrue(mk.nodeExists("/trunk/child1/child2", null));
+        // make sure /trunk/child3 still exists in head
+        assertTrue(mk.nodeExists("/trunk/child3", null));
+    }
+
+    @Test
     public void testSmallBlob() {
         testBlobs(1234, 8 * 1024);
     }

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.java?rev=1402529&r1=1402528&r2=1402529&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/StagedNodeTree.java
Fri Oct 26 14:37:06 2012
@@ -374,7 +374,7 @@ public class StagedNodeTree {
 
         StagedNode stagedNode = getStagedNode(path, true);
 
-        // merge non-conflicting changes
+        // apply our changes
         stagedNode.getProperties().putAll(ourChanges.getAddedProperties());
         stagedNode.getProperties().putAll(ourChanges.getChangedProperties());
         for (String name : ourChanges.getRemovedProperties().keySet()) {
@@ -385,7 +385,9 @@ public class StagedNodeTree {
             stagedNode.add(new ChildNodeEntry(entry.getKey(), entry.getValue()));
         }
         for (Map.Entry<String, Id> entry : ourChanges.getChangedChildNodes().entrySet())
{
-            stagedNode.add(new ChildNodeEntry(entry.getKey(), entry.getValue()));
+            if (!theirChanges.getChangedChildNodes().containsKey(entry.getKey())) {
+                stagedNode.add(new ChildNodeEntry(entry.getKey(), entry.getValue()));
+            }
         }
         for (String name : ourChanges.getRemovedChildNodes().keySet()) {
             stagedNode.remove(name);



Mime
View raw message