Search in sources :

Example 1 with Mapping

use of com.google.gerrit.server.patch.GitPositionTransformer.Mapping in project gerrit by GerritCodeReview.

the class CommentPorter method portSamePatchsetAndSide.

private ImmutableList<HumanComment> portSamePatchsetAndSide(Project.NameKey project, Change change, PatchSet originalPatchset, PatchSet targetPatchset, List<HumanComment> comments, short side) {
    try (TraceTimer ignored = TraceContext.newTimer("Porting comments same patchset and side", Metadata.builder().projectName(project.get()).changeId(change.getChangeId()).patchSetId(originalPatchset.number()).commentSide(side).build())) {
        ImmutableSet<Mapping> mappings;
        try {
            mappings = loadMappings(project, change, originalPatchset, targetPatchset, side);
        } catch (Exception e) {
            logger.atWarning().withCause(e).log("Could not determine some necessary diff mappings for porting comments on change %s" + " from patchset %s to patchset %s. Mapping %d affected comments to the fallback" + " destination.", change.getChangeId(), originalPatchset.id().getId(), targetPatchset.id().getId(), comments.size());
            mappings = getFallbackMappings(comments);
        }
        ImmutableList<PositionedEntity<HumanComment>> positionedComments = comments.stream().map(this::toPositionedEntity).collect(toImmutableList());
        ImmutableMap<PositionedEntity<HumanComment>, HumanComment> origToPortedMap = positionTransformer.transform(positionedComments, mappings).stream().collect(ImmutableMap.toImmutableMap(Function.identity(), PositionedEntity::getEntityAtUpdatedPosition));
        collectMetrics(origToPortedMap);
        return ImmutableList.copyOf(origToPortedMap.values());
    }
}
Also used : PositionedEntity(com.google.gerrit.server.patch.GitPositionTransformer.PositionedEntity) TraceTimer(com.google.gerrit.server.logging.TraceContext.TraceTimer) Mapping(com.google.gerrit.server.patch.GitPositionTransformer.Mapping) FileMapping(com.google.gerrit.server.patch.GitPositionTransformer.FileMapping) HumanComment(com.google.gerrit.entities.HumanComment) DiffNotAvailableException(com.google.gerrit.server.patch.DiffNotAvailableException)

Aggregations

HumanComment (com.google.gerrit.entities.HumanComment)1 TraceTimer (com.google.gerrit.server.logging.TraceContext.TraceTimer)1 DiffNotAvailableException (com.google.gerrit.server.patch.DiffNotAvailableException)1 FileMapping (com.google.gerrit.server.patch.GitPositionTransformer.FileMapping)1 Mapping (com.google.gerrit.server.patch.GitPositionTransformer.Mapping)1 PositionedEntity (com.google.gerrit.server.patch.GitPositionTransformer.PositionedEntity)1