<commit_before>// Copyright (C) 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.restapi.change;

import static com.google.common.collect.ImmutableList.toImmutableList;

import com.google.auto.factory.AutoFactory;
import com.google.auto.factory.Provided;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Table.Cell;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.LabelId;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.PatchSetApproval;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.approval.ApprovalCopier;
import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext;
import com.google.inject.Inject;
import java.io.IOException;
import java.util.Optional;

/**
 * Batch update operation that copy approvals that have been newly applied on outdated patch sets to
 * the follow-up patch sets if they are copyable and no non-copied approvals prevent the copying.
 *
 * <p>Must be invoked after the batch update operation which applied new approvals on outdated patch
 * sets (e.g. after {@link PostReviewOp}.
 */
@AutoFactory
public class PostReviewCopyApprovalsOp implements BatchUpdateOp {
  private final ApprovalCopier approvalCopier;
  private final PatchSetUtil patchSetUtil;
  private final PatchSet.Id patchSetId;

  private ChangeContext ctx;
  private ImmutableList<PatchSet.Id> followUpPatchSets;

  @Inject
  PostReviewCopyApprovalsOp(
      @Provided ApprovalCopier approvalCopier,
      @Provided PatchSetUtil patchSetUtil,
      PatchSet.Id patchSetId) {
    this.approvalCopier = approvalCopier;
    this.patchSetUtil = patchSetUtil;
    this.patchSetId = patchSetId;
  }<commit_msg>PostReviewCopyApprovalsOp: Remove unneeded @Inject annotation<commit_after>// Copyright (C) 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.restapi.change;

import static com.google.common.collect.ImmutableList.toImmutableList;

import com.google.auto.factory.AutoFactory;
import com.google.auto.factory.Provided;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Table.Cell;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.LabelId;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.PatchSetApproval;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.approval.ApprovalCopier;
import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext;
import java.io.IOException;
import java.util.Optional;

/**
 * Batch update operation that copy approvals that have been newly applied on outdated patch sets to
 * the follow-up patch sets if they are copyable and no non-copied approvals prevent the copying.
 *
 * <p>Must be invoked after the batch update operation which applied new approvals on outdated patch
 * sets (e.g. after {@link PostReviewOp}.
 */
@AutoFactory
public class PostReviewCopyApprovalsOp implements BatchUpdateOp {
  private final ApprovalCopier approvalCopier;
  private final PatchSetUtil patchSetUtil;
  private final PatchSet.Id patchSetId;

  private ChangeContext ctx;
  private ImmutableList<PatchSet.Id> followUpPatchSets;

  PostReviewCopyApprovalsOp(
      @Provided ApprovalCopier approvalCopier,
      @Provided PatchSetUtil patchSetUtil,
      PatchSet.Id patchSetId) {
    this.approvalCopier = approvalCopier;
    this.patchSetUtil = patchSetUtil;
    this.patchSetId = patchSetId;
  }
{'fraction_non_alphanumeric': 0.08199457542249114, 'fraction_numerical': 0.003338201543918214, 'mean_word_length': 4.700356718192628, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5014479', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1332, 'n_words': 431}