diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java index d4ad1edd00..33de4d7e7b 100644 --- a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java +++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/MergingNodeStateDiff.java @@ -164,13 +164,12 @@ public final class MergingNodeStateDiff extends DefaultNodeStateDiff { private void applyPropertyResolution(Resolution resolution, ConflictType conflictType, String name, PropertyState ours) { NodeBuilder conflictMarker = getConflictMarker(conflictType); if (resolution == Resolution.OURS) { - if (DELETE_CHANGED_PROPERTY == conflictType) { + if (ours == null) { + // DELETE_CHANGED_PROPERTY or DELETE_DELETED_PROPERTY target.removeProperty(name); - } - else { + } else { target.setProperty(ours); } - } NodeBuilder baseClean = conflictMarker.getChildNode(ConflictAnnotatingRebaseDiff.BASE); if (baseClean.exists()) { @@ -185,10 +184,9 @@ public final class MergingNodeStateDiff extends DefaultNodeStateDiff { private void applyResolution(Resolution resolution, ConflictType conflictType, String name, NodeState ours) { NodeBuilder conflictMarker = getConflictMarker(conflictType); if (resolution == Resolution.OURS) { - if (DELETE_CHANGED_NODE == conflictType) { + if (DELETE_CHANGED_NODE == conflictType || DELETE_DELETED_NODE == conflictType) { removeChild(target, name); - } - else { + } else { addChild(target, name, ours); } } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerOursTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerOursTest.java index fd826da782..18cdb84058 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerOursTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerOursTest.java @@ -74,7 +74,7 @@ public class DefaultThreeWayConflictHandlerOursTest { } @Test - public void testAddExistingProperties() throws CommitFailedException { + public void testAddExistingProperty() throws CommitFailedException { theirRoot.getTree("/").setProperty("p", THEIR_VALUE); theirRoot.getTree("/").setProperty("q", THEIR_VALUE); ourRoot.getTree("/").setProperty("p", OUR_VALUE); @@ -119,6 +119,18 @@ public class DefaultThreeWayConflictHandlerOursTest { } @Test + public void testDeleteDeletedProperty() throws CommitFailedException { + theirRoot.getTree("/").removeProperty("a"); + ourRoot.getTree("/").removeProperty("a"); + + theirRoot.commit(); + ourRoot.commit(); + + PropertyState p = ourRoot.getTree("/").getProperty("a"); + assertNull(p); + } + + @Test public void testDeleteChangedProperty() throws CommitFailedException { theirRoot.getTree("/").setProperty("a", THEIR_VALUE); ourRoot.getTree("/").removeProperty("a"); @@ -168,4 +180,15 @@ public class DefaultThreeWayConflictHandlerOursTest { assertFalse(n.exists()); } + @Test + public void testDeleteDeletedNode() throws CommitFailedException { + theirRoot.getTree("/x").remove(); + ourRoot.getTree("/x").remove(); + + theirRoot.commit(); + ourRoot.commit(); + + assertFalse(ourRoot.getTree("/x").exists()); + } + } diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerTheirsTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerTheirsTest.java index a54e0fad75..0cc2802b33 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerTheirsTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultThreeWayConflictHandlerTheirsTest.java @@ -74,7 +74,7 @@ public class DefaultThreeWayConflictHandlerTheirsTest { } @Test - public void testAddExistingProperties() throws CommitFailedException { + public void testAddExistingProperty() throws CommitFailedException { theirRoot.getTree("/").setProperty("p", THEIR_VALUE); theirRoot.getTree("/").setProperty("q", THEIR_VALUE); ourRoot.getTree("/").setProperty("p", OUR_VALUE); @@ -118,6 +118,18 @@ public class DefaultThreeWayConflictHandlerTheirsTest { } @Test + public void testDeleteDeletedProperty() throws CommitFailedException { + theirRoot.getTree("/").removeProperty("a"); + ourRoot.getTree("/").removeProperty("a"); + + theirRoot.commit(); + ourRoot.commit(); + + PropertyState p = ourRoot.getTree("/").getProperty("a"); + assertNull(p); + } + + @Test public void testDeleteChangedProperty() throws CommitFailedException { theirRoot.getTree("/").setProperty("a", THEIR_VALUE); ourRoot.getTree("/").removeProperty("a"); @@ -168,4 +180,14 @@ public class DefaultThreeWayConflictHandlerTheirsTest { assertEquals(THEIR_VALUE, n.getProperty("p").getValue(STRING)); } + @Test + public void testDeleteDeletedNode() throws CommitFailedException { + theirRoot.getTree("/x").remove(); + ourRoot.getTree("/x").remove(); + + theirRoot.commit(); + ourRoot.commit(); + + assertFalse(ourRoot.getTree("/x").exists()); + } }