/** * This implementation is equal to first rebasing the builder and then applying it to a * new branch and immediately merging it back. * @param builder the builder whose changes to apply * @param commitHook the commit hook to apply while merging changes * @return the node state resulting from the merge. * @throws CommitFailedException * @throws IllegalArgumentException if the builder is not acquired from a root state of * this store */ @Override public synchronized NodeState merge( @NotNull NodeBuilder builder, @NotNull CommitHook commitHook, @NotNull CommitInfo info) throws CommitFailedException { checkArgument(builder instanceof MemoryNodeBuilder); MemoryNodeBuilder mnb = (MemoryNodeBuilder) builder; checkArgument(mnb.isRoot()); checkNotNull(commitHook); rebase(builder); NodeStoreBranch branch = new MemoryNodeStoreBranch(this, getRoot()); branch.setRoot(builder.getNodeState()); NodeState merged = branch.merge(commitHook, info); mnb.reset(merged); return merged; }
/** * This implementation is equal to first rebasing the builder and then applying it to a * new branch and immediately merging it back. * @param builder the builder whose changes to apply * @param commitHook the commit hook to apply while merging changes * @return the node state resulting from the merge. * @throws CommitFailedException * @throws IllegalArgumentException if the builder is not acquired from a root state of * this store */ @Override public synchronized NodeState merge( @Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook, @Nonnull CommitInfo info) throws CommitFailedException { checkArgument(builder instanceof MemoryNodeBuilder); MemoryNodeBuilder mnb = (MemoryNodeBuilder) builder; checkArgument(mnb.isRoot()); checkNotNull(commitHook); rebase(builder); NodeStoreBranch branch = new MemoryNodeStoreBranch(this, getRoot()); branch.setRoot(builder.getNodeState()); NodeState merged = branch.merge(commitHook, info); mnb.reset(merged); return merged; }