use of org.eclipse.jgit.revwalk.RevCommitList in project gerrit by GerritCodeReview.
the class MergeSorter method sort.
Collection<CodeReviewCommit> sort(final Collection<CodeReviewCommit> toMerge) throws IOException {
final Set<CodeReviewCommit> heads = new HashSet<>();
final Set<CodeReviewCommit> sort = new HashSet<>(toMerge);
while (!sort.isEmpty()) {
final CodeReviewCommit n = removeOne(sort);
rw.resetRetain(canMergeFlag);
rw.markStart(n);
for (RevCommit c : accepted) {
rw.markUninteresting(c);
}
CodeReviewCommit c;
RevCommitList<RevCommit> contents = new RevCommitList<>();
while ((c = rw.next()) != null) {
if (!c.has(canMergeFlag) || !incoming.contains(c)) {
// We cannot merge n as it would bring something we
// aren't permitted to merge at this time. Drop n.
//
n.setStatusCode(CommitMergeStatus.MISSING_DEPENDENCY);
break;
}
contents.add(c);
}
if (n.getStatusCode() == CommitMergeStatus.MISSING_DEPENDENCY) {
continue;
}
// Anything reachable through us is better merged by just
// merging us directly. So prune our ancestors out and let
// us merge instead.
//
sort.removeAll(contents);
heads.removeAll(contents);
heads.add(n);
}
return heads;
}
use of org.eclipse.jgit.revwalk.RevCommitList in project gerrit by GerritCodeReview.
the class MergeSorter method sort.
public Collection<CodeReviewCommit> sort(Collection<CodeReviewCommit> toMerge) throws IOException {
final Set<CodeReviewCommit> heads = new HashSet<>();
final Set<CodeReviewCommit> sort = new HashSet<>(toMerge);
while (!sort.isEmpty()) {
final CodeReviewCommit n = removeOne(sort);
rw.resetRetain(canMergeFlag);
rw.markStart(n);
for (RevCommit c : accepted) {
rw.markUninteresting(c);
}
CodeReviewCommit c;
RevCommitList<RevCommit> contents = new RevCommitList<>();
while ((c = rw.next()) != null) {
if (!c.has(canMergeFlag) || !incoming.contains(c)) {
// We cannot merge n as it would bring something we
// aren't permitted to merge at this time. Drop n.
//
n.setStatusCode(CommitMergeStatus.MISSING_DEPENDENCY);
n.setStatusMessage(CommitMergeStatus.createMissingDependencyMessage(caller, queryProvider, n.name(), c.name()));
break;
}
contents.add(c);
}
if (n.getStatusCode() == CommitMergeStatus.MISSING_DEPENDENCY) {
continue;
}
// Anything reachable through us is better merged by just
// merging us directly. So prune our ancestors out and let
// us merge instead.
//
sort.removeAll(contents);
heads.removeAll(contents);
heads.add(n);
}
return heads;
}
Aggregations