@Override protected ConflictAnnotatingRebaseDiff createDiff(NodeBuilder builder, String name) { return new ConflictAnnotatingRebaseDiff(builder.child(name)); }
@Override protected void deleteDeletedNode(NodeBuilder builder, String name, NodeState before) { NodeBuilder cb = conflictMarker(builder, DELETE_DELETED_NODE); cb.child(BASE).setChildNode(name, before); }
@Override protected ConflictAnnotatingRebaseDiff createDiff(NodeBuilder builder, String name) { return new ConflictAnnotatingRebaseDiff(builder.child(name)); }
@Override protected void deleteDeletedNode(NodeBuilder builder, String name, NodeState before) { NodeBuilder cb = conflictMarker(builder, DELETE_DELETED_NODE); cb.child(BASE).setChildNode(name, before); }
@Override @NotNull public NodeState rebase(@NotNull NodeBuilder builder) { checkArgument(builder instanceof SegmentNodeBuilder); SegmentNodeBuilder snb = (SegmentNodeBuilder) builder; NodeState root = getRoot(); NodeState before = snb.getBaseState(); if (!SegmentNodeState.fastEquals(before, root)) { SegmentNodeState after = snb.getNodeState(); snb.reset(root); after.compareAgainstBaseState( before, new ConflictAnnotatingRebaseDiff(snb)); } return snb.getNodeState(); }
@Override protected void deleteChangedNode(NodeBuilder builder, String name, NodeState before) { NodeBuilder cb = conflictMarker(builder, DELETE_CHANGED_NODE); cb.child(BASE).setChildNode(name, before); }
/** * This implementation is equal to applying the differences between the builders base state * and its head state to a fresh builder on the stores root state using * {@link org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff} for resolving * conflicts. * @param builder the builder to rebase * @return the node state resulting from the rebase. * @throws IllegalArgumentException if the builder is not acquired from a root state of * this store */ @Override public NodeState rebase(@NotNull NodeBuilder builder) { checkArgument(builder instanceof MemoryNodeBuilder); NodeState head = checkNotNull(builder).getNodeState(); NodeState base = builder.getBaseState(); NodeState newBase = getRoot(); if (base != newBase) { ((MemoryNodeBuilder) builder).reset(newBase); head.compareAgainstBaseState( base, new ConflictAnnotatingRebaseDiff(builder)); head = builder.getNodeState(); } return head; }
@Override protected void deleteChangedProperty(NodeBuilder builder, PropertyState before) { NodeBuilder cb = conflictMarker(builder, DELETE_CHANGED_PROPERTY); cb.child(BASE).setProperty(before); }
/** * This implementation is equal to applying the differences between the builders base state * and its head state to a fresh builder on the stores root state using * {@link org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff} for resolving * conflicts. * @param builder the builder to rebase * @return the node state resulting from the rebase. * @throws IllegalArgumentException if the builder is not acquired from a root state of * this store */ @Override public NodeState rebase(@Nonnull NodeBuilder builder) { checkArgument(builder instanceof MemoryNodeBuilder); NodeState head = checkNotNull(builder).getNodeState(); NodeState base = builder.getBaseState(); NodeState newBase = getRoot(); if (base != newBase) { ((MemoryNodeBuilder) builder).reset(newBase); head.compareAgainstBaseState( base, new ConflictAnnotatingRebaseDiff(builder)); head = builder.getNodeState(); } return head; }
@Override protected void deleteChangedNode(NodeBuilder builder, String name, NodeState before) { NodeBuilder cb = conflictMarker(builder, DELETE_CHANGED_NODE); cb.child(BASE).setChildNode(name, before); }
@Override void rebase() { DocumentNodeState root = store.getRoot(); // is a rebase necessary? if (root.getRootRevision().equals(base.getRootRevision())) { // fresh root is still at the same revision as // the base of the branch return; } NodeBuilder builder = new MemoryNodeBuilder(root); head.compareAgainstBaseState(base, new ConflictAnnotatingRebaseDiff(builder)); base = root; head = newModifiedDocumentNodeState(builder.getNodeState()); }
@Override protected void deleteDeletedProperty(NodeBuilder builder, PropertyState before) { NodeBuilder cb = conflictMarker(builder, DELETE_DELETED_PROPERTY); cb.child(BASE).setProperty(before); }
@Override void rebase() { DocumentNodeState root = store.getRoot(); // is a rebase necessary? if (root.getRootRevision().equals(base.getRootRevision())) { // fresh root is still at the same revision as // the base of the branch return; } NodeBuilder builder = new MemoryNodeBuilder(root); head.compareAgainstBaseState(base, new ConflictAnnotatingRebaseDiff(builder)); base = root; head = newModifiedDocumentNodeState(builder.getNodeState()); }
@Override protected void deleteChangedProperty(NodeBuilder builder, PropertyState before) { NodeBuilder cb = conflictMarker(builder, DELETE_CHANGED_PROPERTY); cb.child(BASE).setProperty(before); }
/** * Rebase this builder on top of the head of the underlying store */ NodeState rebase() { NodeState head = super.getNodeState(); NodeState inMemBase = super.getBaseState(); // Rebase branch branch.rebase(); // Rebase in memory changes on top of the head of the rebased branch super.reset(branch.getHead()); updates = 0; head.compareAgainstBaseState(inMemBase, new ConflictAnnotatingRebaseDiff(this)); // Set new base and return rebased head base = branch.getBase(); return super.getNodeState(); }
@Override protected void deleteDeletedProperty(NodeBuilder builder, PropertyState before) { NodeBuilder cb = conflictMarker(builder, DELETE_DELETED_PROPERTY); cb.child(BASE).setProperty(before); }
/** * Rebase this builder on top of the head of the underlying store */ NodeState rebase() { NodeState head = super.getNodeState(); NodeState inMemBase = super.getBaseState(); // Rebase branch branch.rebase(); // Rebase in memory changes on top of the head of the rebased branch super.reset(branch.getHead()); updates = 0; head.compareAgainstBaseState(inMemBase, new ConflictAnnotatingRebaseDiff(this)); // Set new base and return rebased head base = branch.getBase(); return super.getNodeState(); }
@Override protected void changeDeletedNode(NodeBuilder builder, String name, NodeState after, NodeState base) { NodeBuilder cb = conflictMarker(builder, CHANGE_DELETED_NODE); cb.child(BASE).setChildNode(name, base); cb.child(OURS).setChildNode(name, after); }
/** * Apply the changes represented by this commit to the passed {@code base} * node state. * * @param base * the base node state to apply this commit to * @return the resulting state from applying this commit to {@code base}. * @throws CommitFailedException * if the commit cannot be applied to {@code base}. (e.g. * because of a conflict.) */ public SegmentNodeState apply(SegmentNodeState base) throws CommitFailedException { SegmentNodeBuilder builder = base.builder(); if (SegmentNodeState.fastEquals(changes.getBaseState(), base.getChildNode(ROOT))) { // use a shortcut when there are no external changes NodeState before = changes.getBaseState(); NodeState after = changes.getNodeState(); builder.setChildNode(ROOT, hook.processCommit(before, after, info)); } else { // there were some external changes, so do the full rebase ConflictAnnotatingRebaseDiff diff = new ConflictAnnotatingRebaseDiff(builder.child(ROOT)); changes.getNodeState().compareAgainstBaseState(changes.getBaseState(), diff); // apply commit hooks on the rebased changes builder.setChildNode(ROOT, hook.processCommit(builder.getBaseState().getChildNode(ROOT), builder.getNodeState().getChildNode(ROOT), info)); } return builder.getNodeState(); }
@Override protected void changeDeletedNode(NodeBuilder builder, String name, NodeState after, NodeState base) { NodeBuilder cb = conflictMarker(builder, CHANGE_DELETED_NODE); cb.child(BASE).setChildNode(name, base); cb.child(OURS).setChildNode(name, after); }