Index: oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java (revision 1777088) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java (working copy) @@ -20,9 +20,12 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Lists.newArrayList; import static org.apache.jackrabbit.oak.commons.PathUtils.elements; import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute; +import java.util.List; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -355,16 +358,18 @@ } private boolean applyPendingMoves() { - boolean movesApplied = false; - if (parent != null) { - movesApplied = parent.applyPendingMoves(); + List hierarchy = newArrayList(); + for (MutableTree t = this; t != null; t = t.parent) { + hierarchy.add(t); } - Move old = pendingMoves; - pendingMoves = pendingMoves.apply(this); - if (pendingMoves != old) { - movesApplied = true; + boolean result = false; + for (int i = hierarchy.size() - 1; i >= 0; i--) { + MutableTree tree = hierarchy.get(i); + Move old = tree.pendingMoves; + tree.pendingMoves = old.apply(tree); + result = result || old != tree.pendingMoves; } - return movesApplied; + return result; } }