Search in sources :

Example 1 with GroupCollector

use of com.google.gerrit.server.git.GroupCollector in project gerrit by GerritCodeReview.

the class Schema_108 method updateProjectGroups.

private void updateProjectGroups(ReviewDb db, Repository repo, RevWalk rw, Set<Change.Id> changes, UpdateUI ui) throws OrmException, IOException {
    // Match sorting in ReceiveCommits.
    rw.reset();
    rw.sort(RevSort.TOPO);
    rw.sort(RevSort.REVERSE, true);
    RefDatabase refdb = repo.getRefDatabase();
    for (Ref ref : refdb.getRefs(Constants.R_HEADS).values()) {
        RevCommit c = maybeParseCommit(rw, ref.getObjectId(), ui);
        if (c != null) {
            rw.markUninteresting(c);
        }
    }
    ListMultimap<ObjectId, Ref> changeRefsBySha = MultimapBuilder.hashKeys().arrayListValues().build();
    ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha = MultimapBuilder.hashKeys().arrayListValues().build();
    for (Ref ref : refdb.getRefs(RefNames.REFS_CHANGES).values()) {
        ObjectId id = ref.getObjectId();
        if (ref.getObjectId() == null) {
            continue;
        }
        id = id.copy();
        changeRefsBySha.put(id, ref);
        PatchSet.Id psId = PatchSet.Id.fromRef(ref.getName());
        if (psId != null && changes.contains(psId.getParentKey())) {
            patchSetsBySha.put(id, psId);
            RevCommit c = maybeParseCommit(rw, id, ui);
            if (c != null) {
                rw.markStart(c);
            }
        }
    }
    GroupCollector collector = GroupCollector.createForSchemaUpgradeOnly(changeRefsBySha, db);
    RevCommit c;
    while ((c = rw.next()) != null) {
        collector.visit(c);
    }
    updateGroups(db, collector, patchSetsBySha);
}
Also used : GroupCollector(com.google.gerrit.server.git.GroupCollector) Ref(org.eclipse.jgit.lib.Ref) ObjectId(org.eclipse.jgit.lib.ObjectId) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) ObjectId(org.eclipse.jgit.lib.ObjectId) RefDatabase(org.eclipse.jgit.lib.RefDatabase) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 GroupCollector (com.google.gerrit.server.git.GroupCollector)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 Ref (org.eclipse.jgit.lib.Ref)1 RefDatabase (org.eclipse.jgit.lib.RefDatabase)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1