commitQueue.add(new CommitNode(startPoint, 1)); while (!commitQueue.isEmpty()) { CommitNode node = commitQueue.remove(); switch (evaluation) { case INCLUDE_AND_PRUNE: parents = getParents(node.getObjectId()); apply(node, parents); break; case INCLUDE_AND_CONTINUE: parents = getParents(node.getObjectId()); apply(node, parents); addParents(node, parents); break; case EXCLUDE_AND_PRUNE: if (existsInDestination(node.getObjectId()) && !have.contains(node.getObjectId())) { have.add(node.getObjectId()); parents = getParents(node.getObjectId()); addParents(node, parents); if (existsInDestination(node.getObjectId()) && !have.contains(node.getObjectId())) { have.add(node.getObjectId());
@Override protected Evaluation evaluate(CommitNode commitNode) { if (limit.isPresent() && commitNode.getDepth() > limit.get()) { return Evaluation.EXCLUDE_AND_PRUNE; } else if (!source.objectExists(commitNode.getObjectId())) { // remote history is shallow return Evaluation.EXCLUDE_AND_PRUNE; } boolean exists = destination.objectExists(commitNode.getObjectId()); if (!limit.isPresent() && exists) { // calculate the new fetch limit limit = Optional.of( destination.getDepth(commitNode.getObjectId()) + commitNode.getDepth() - 1); } if (exists) { return Evaluation.EXCLUDE_AND_CONTINUE; } return Evaluation.INCLUDE_AND_CONTINUE; }
commitQueue.add(new CommitNode(startPoint, 1)); while (!commitQueue.isEmpty()) { CommitNode node = commitQueue.remove(); switch (evaluation) { case INCLUDE_AND_PRUNE: parents = getParents(node.getObjectId()); apply(node, parents); break; case INCLUDE_AND_CONTINUE: parents = getParents(node.getObjectId()); apply(node, parents); addParents(node, parents); break; case EXCLUDE_AND_PRUNE: if (existsInDestination(node.getObjectId()) && !have.contains(node.getObjectId())) { have.add(node.getObjectId()); parents = getParents(node.getObjectId()); addParents(node, parents); if (existsInDestination(node.getObjectId()) && !have.contains(node.getObjectId())) { have.add(node.getObjectId());
@Override protected Evaluation evaluate(CommitNode commitNode) { if (limit.isPresent() && commitNode.getDepth() > limit.get()) { return Evaluation.EXCLUDE_AND_PRUNE; } else if (!source.objectExists(commitNode.getObjectId())) { // remote history is shallow return Evaluation.EXCLUDE_AND_PRUNE; } boolean exists = destination.objectExists(commitNode.getObjectId()); if (!limit.isPresent() && exists) { // calculate the new fetch limit limit = Optional.of( destination.getDepth(commitNode.getObjectId()) + commitNode.getDepth() - 1); } if (exists) { return Evaluation.EXCLUDE_AND_CONTINUE; } return Evaluation.INCLUDE_AND_CONTINUE; }
/** * Add the given commit's parents to the traversal queue. * * @param commitNode the commit whose parents need to be added */ private void addParents(CommitNode commitNode, ImmutableList<ObjectId> parents) { for (ObjectId parent : parents) { CommitNode parentNode = new CommitNode(parent, commitNode.getDepth() + 1); if (commitQueue.contains(parentNode)) { commitQueue.remove(parentNode); } commitQueue.add(parentNode); } }
/** * Add the given commit's parents to the traversal queue. * * @param commitNode the commit whose parents need to be added */ private void addParents(CommitNode commitNode, ImmutableList<ObjectId> parents) { for (ObjectId parent : parents) { CommitNode parentNode = new CommitNode(parent, commitNode.getDepth() + 1); if (commitQueue.contains(parentNode)) { commitQueue.remove(parentNode); } commitQueue.add(parentNode); } }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (!source.graphDatabase().getMapping(commitNode.getObjectId()) .equals(ObjectId.NULL)) { return Evaluation.EXCLUDE_AND_PRUNE; } return Evaluation.INCLUDE_AND_CONTINUE; }
/** * Process the accepted commit node. * * @param commitNode the commit to apply */ protected void apply(CommitNode commitNode, ImmutableList<ObjectId> parents) { if (commits.contains(commitNode.getObjectId())) { commits.remove(commitNode.getObjectId()); } commits.add(commitNode.getObjectId()); }
/** * Process the accepted commit node. * * @param commitNode the commit to apply */ protected void apply(CommitNode commitNode, ImmutableList<ObjectId> parents) { if (commits.contains(commitNode.getObjectId())) { commits.remove(commitNode.getObjectId()); } commits.add(commitNode.getObjectId()); }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (!source.graphDatabase().getMapping(commitNode.getObjectId()) .equals(ObjectId.NULL)) { return Evaluation.EXCLUDE_AND_PRUNE; } return Evaluation.INCLUDE_AND_CONTINUE; }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.objectExists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } else { return Evaluation.INCLUDE_AND_CONTINUE; } }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.graphDatabase().exists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } return Evaluation.INCLUDE_AND_CONTINUE; }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.objectExists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } else { return Evaluation.INCLUDE_AND_CONTINUE; } }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.objectExists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } if (!commitNode.getObjectId().equals(ObjectId.NULL) && !source.objectExists(commitNode.getObjectId())) { // Source is too shallow throw new SynchronizationException(StatusCode.HISTORY_TOO_SHALLOW); } return Evaluation.INCLUDE_AND_CONTINUE; }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.graphDatabase().exists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } return Evaluation.INCLUDE_AND_CONTINUE; }
@Override protected Evaluation evaluate(CommitNode commitNode) { if (destination.objectExists(commitNode.getObjectId())) { return Evaluation.EXCLUDE_AND_PRUNE; } if (!commitNode.getObjectId().equals(ObjectId.NULL) && !source.objectExists(commitNode.getObjectId())) { // Source is too shallow throw new SynchronizationException(StatusCode.HISTORY_TOO_SHALLOW); } return Evaluation.INCLUDE_AND_CONTINUE; }