Fix: Rebase did not mail all reviewers

Change-Id: I09e61d8156272a9d5f4227d9d59ebfde5d3eda04
This commit is contained in:
Gustaf Lundh
2012-05-08 12:04:37 -07:00
parent df4d086065
commit 9d79fbe932
2 changed files with 17 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.PatchSetInfo; import com.google.gerrit.reviewdb.client.PatchSetInfo;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.io.IOException; import java.io.IOException;
@@ -65,8 +66,9 @@ public class ApprovalsUtil {
* @param change Change to update * @param change Change to update
* @throws OrmException * @throws OrmException
* @throws IOException * @throws IOException
* @return List<PatchSetApproval> The previous approvals
*/ */
public void copyVetosToLatestPatchSet(Change change) public List<PatchSetApproval> copyVetosToLatestPatchSet(Change change)
throws OrmException, IOException { throws OrmException, IOException {
PatchSet.Id source; PatchSet.Id source;
if (change.getNumberOfPatchSets() > 1) { if (change.getNumberOfPatchSets() > 1) {
@@ -76,16 +78,20 @@ public class ApprovalsUtil {
} }
PatchSet.Id dest = change.currPatchSetId(); PatchSet.Id dest = change.currPatchSetId();
for (PatchSetApproval a : db.patchSetApprovals().byPatchSet(source)) { List<PatchSetApproval> patchSetApprovals = db.patchSetApprovals().byChange(change.getId()).toList();
for (PatchSetApproval a : patchSetApprovals) {
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store // ApprovalCategory.SUBMIT is still in db but not relevant in git-store
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) { if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
final ApprovalType type = approvalTypes.byId(a.getCategoryId()); final ApprovalType type = approvalTypes.byId(a.getCategoryId());
if (type.getCategory().isCopyMinScore() && type.isMaxNegative(a)) { if (a.getPatchSetId().equals(source) &&
type.getCategory().isCopyMinScore() &&
type.isMaxNegative(a)) {
db.patchSetApprovals().insert( db.patchSetApprovals().insert(
Collections.singleton(new PatchSetApproval(dest, a))); Collections.singleton(new PatchSetApproval(dest, a)));
} }
} }
} }
return patchSetApprovals;
} }

View File

@@ -383,18 +383,12 @@ public class ChangeUtil {
replication.scheduleUpdate(change.getProject(), ru.getName()); replication.scheduleUpdate(change.getProject(), ru.getName());
approvalsUtil.copyVetosToLatestPatchSet(change); List<PatchSetApproval> patchSetApprovals = approvalsUtil.copyVetosToLatestPatchSet(change);
final ChangeMessage cmsg =
new ChangeMessage(new ChangeMessage.Key(changeId,
ChangeUtil.messageUUID(db)), user.getAccountId(), patchSetId);
cmsg.setMessage("Patch Set " + patchSetId.get() + ": Rebased");
db.changeMessages().insert(Collections.singleton(cmsg));
final Set<Account.Id> oldReviewers = new HashSet<Account.Id>(); final Set<Account.Id> oldReviewers = new HashSet<Account.Id>();
final Set<Account.Id> oldCC = new HashSet<Account.Id>(); final Set<Account.Id> oldCC = new HashSet<Account.Id>();
for (PatchSetApproval a : db.patchSetApprovals().byChange(change.getId())) { for (PatchSetApproval a : patchSetApprovals) {
if (a.getValue() != 0) { if (a.getValue() != 0) {
oldReviewers.add(a.getAccountId()); oldReviewers.add(a.getAccountId());
} else { } else {
@@ -402,6 +396,12 @@ public class ChangeUtil {
} }
} }
final ChangeMessage cmsg =
new ChangeMessage(new ChangeMessage.Key(changeId,
ChangeUtil.messageUUID(db)), user.getAccountId(), patchSetId);
cmsg.setMessage("Patch Set " + patchSetId.get() + ": Rebased");
db.changeMessages().insert(Collections.singleton(cmsg));
final ReplacePatchSetSender cm = final ReplacePatchSetSender cm =
rebasedPatchSetSenderFactory.create(change); rebasedPatchSetSenderFactory.create(change);
cm.setFrom(user.getAccountId()); cm.setFrom(user.getAccountId());