Search in sources :

Example 1 with Sets

use of com.google.common.collect.Sets in project gerrit by GerritCodeReview.

the class ChangeNotesParser method updatePatchSetStates.

private void updatePatchSetStates() {
    Set<PatchSet.Id> missing = new TreeSet<>(ReviewDbUtil.intKeyOrdering());
    for (Iterator<PatchSet> it = patchSets.values().iterator(); it.hasNext(); ) {
        PatchSet ps = it.next();
        if (ps.getRevision().equals(PARTIAL_PATCH_SET)) {
            missing.add(ps.getId());
            it.remove();
        }
    }
    for (Map.Entry<PatchSet.Id, PatchSetState> e : patchSetStates.entrySet()) {
        switch(e.getValue()) {
            case PUBLISHED:
            default:
                break;
            case DELETED:
                patchSets.remove(e.getKey());
                break;
            case DRAFT:
                PatchSet ps = patchSets.get(e.getKey());
                if (ps != null) {
                    ps.setDraft(true);
                }
                break;
        }
    }
    // Post-process other collections to remove items corresponding to deleted
    // (or otherwise missing) patch sets. This is safer than trying to prevent
    // insertion, as it will also filter out items racily added after the patch
    // set was deleted.
    changeMessagesByPatchSet.keys().retainAll(patchSets.keySet());
    int pruned = pruneEntitiesForMissingPatchSets(allChangeMessages, ChangeMessage::getPatchSetId, missing);
    pruned += pruneEntitiesForMissingPatchSets(comments.values(), c -> new PatchSet.Id(id, c.key.patchSetId), missing);
    pruned += pruneEntitiesForMissingPatchSets(approvals.values(), PatchSetApproval::getPatchSetId, missing);
    if (!missing.isEmpty()) {
        log.warn("ignoring {} additional entities due to missing patch sets: {}", pruned, missing);
    }
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) FOOTER_SUBMITTED_WITH(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMITTED_WITH) ListMultimap(com.google.common.collect.ListMultimap) MultimapBuilder(com.google.common.collect.MultimapBuilder) LoggerFactory(org.slf4j.LoggerFactory) FOOTER_HASHTAGS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS) HashBasedTable(com.google.common.collect.HashBasedTable) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) ReviewerSet(com.google.gerrit.server.ReviewerSet) FooterKey(org.eclipse.jgit.revwalk.FooterKey) FOOTER_ASSIGNEE(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_ASSIGNEE) Comment(com.google.gerrit.reviewdb.client.Comment) InvalidObjectIdException(org.eclipse.jgit.errors.InvalidObjectIdException) FOOTER_PATCH_SET_DESCRIPTION(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET_DESCRIPTION) Tables(com.google.common.collect.Tables) Locale(java.util.Locale) Map(java.util.Map) GitDateParser(org.eclipse.jgit.util.GitDateParser) ParseException(java.text.ParseException) Splitter(com.google.common.base.Splitter) NoteMap(org.eclipse.jgit.notes.NoteMap) LinkedListMultimap(com.google.common.collect.LinkedListMultimap) Timer1(com.google.gerrit.metrics.Timer1) FOOTER_WORK_IN_PROGRESS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS) CHANGES(com.google.gerrit.server.notedb.NoteDbTable.CHANGES) ImmutableSet(com.google.common.collect.ImmutableSet) FOOTER_SUBJECT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBJECT) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) RawParseUtils(org.eclipse.jgit.util.RawParseUtils) ChangeNotesRevWalk(com.google.gerrit.server.notedb.ChangeNotesCommit.ChangeNotesRevWalk) Set(java.util.Set) ReviewerStatusUpdate(com.google.gerrit.server.ReviewerStatusUpdate) LabelType(com.google.gerrit.common.data.LabelType) Collectors.joining(java.util.stream.Collectors.joining) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) PersonIdent(org.eclipse.jgit.lib.PersonIdent) List(java.util.List) FOOTER_STATUS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_STATUS) RefNames(com.google.gerrit.reviewdb.client.RefNames) AutoValue(com.google.auto.value.AutoValue) Optional(java.util.Optional) FOOTER_LABEL(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_LABEL) LabelId(com.google.gerrit.reviewdb.client.LabelId) FOOTER_READ_ONLY_UNTIL(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_READ_ONLY_UNTIL) FOOTER_SUBMISSION_ID(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMISSION_ID) FOOTER_COMMIT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COMMIT) FOOTER_CHANGE_ID(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHANGE_ID) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) Change(com.google.gerrit.reviewdb.client.Change) HashMap(java.util.HashMap) Function(java.util.function.Function) TreeSet(java.util.TreeSet) Enums(com.google.common.base.Enums) SubmitRecord(com.google.gerrit.common.data.SubmitRecord) ArrayList(java.util.ArrayList) FOOTER_TAG(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TAG) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) FOOTER_REAL_USER(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_REAL_USER) Lists(com.google.common.collect.Lists) Charset(java.nio.charset.Charset) Account(com.google.gerrit.reviewdb.client.Account) FOOTER_BRANCH(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_BRANCH) FOOTER_PATCH_SET(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET) FOOTER_GROUPS(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_GROUPS) FOOTER_PRIVATE(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PRIVATE) FOOTER_TOPIC(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) FOOTER_CURRENT(com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CURRENT) ReviewDbUtil(com.google.gerrit.reviewdb.server.ReviewDbUtil) IOException(java.io.IOException) Ints(com.google.common.primitives.Ints) ObjectId(org.eclipse.jgit.lib.ObjectId) Address(com.google.gerrit.server.mail.Address) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) LabelVote(com.google.gerrit.server.util.LabelVote) ReviewerByEmailSet(com.google.gerrit.server.ReviewerByEmailSet) Table(com.google.common.collect.Table) Collections(java.util.Collections) ObjectReader(org.eclipse.jgit.lib.ObjectReader) RevId(com.google.gerrit.reviewdb.client.RevId) TreeSet(java.util.TreeSet) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) LabelId(com.google.gerrit.reviewdb.client.LabelId) ObjectId(org.eclipse.jgit.lib.ObjectId) RevId(com.google.gerrit.reviewdb.client.RevId) Map(java.util.Map) NoteMap(org.eclipse.jgit.notes.NoteMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

AutoValue (com.google.auto.value.AutoValue)1 Enums (com.google.common.base.Enums)1 Splitter (com.google.common.base.Splitter)1 HashBasedTable (com.google.common.collect.HashBasedTable)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 LinkedListMultimap (com.google.common.collect.LinkedListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 Lists (com.google.common.collect.Lists)1 MultimapBuilder (com.google.common.collect.MultimapBuilder)1 Sets (com.google.common.collect.Sets)1 Table (com.google.common.collect.Table)1 Tables (com.google.common.collect.Tables)1 Ints (com.google.common.primitives.Ints)1 LabelType (com.google.gerrit.common.data.LabelType)1 SubmitRecord (com.google.gerrit.common.data.SubmitRecord)1 Timer1 (com.google.gerrit.metrics.Timer1)1 Account (com.google.gerrit.reviewdb.client.Account)1 Change (com.google.gerrit.reviewdb.client.Change)1 ChangeMessage (com.google.gerrit.reviewdb.client.ChangeMessage)1 Comment (com.google.gerrit.reviewdb.client.Comment)1