Clean up ChangeInserter similar to PatchSetInserter

Remove the commitMessageNotForChange branch. CherryPickChange doesn't
even use this anymore. Don't require setting the ChangeMessage, just
the message string.

Unlike PatchSetInserter, ChangeInserter creates the PatchSet
immediately, because it doesn't have to scan refs to determine the
next patch set ID (it's always 1).

Change-Id: I166374c197413cad8d9036790d252154f9a0b9aa
This commit is contained in:
Dave Borowitz
2015-10-07 18:39:41 -04:00
parent d79945ec18
commit 045022ff83
4 changed files with 42 additions and 70 deletions

View File

@@ -1726,19 +1726,12 @@ public class ReceiveCommits {
CheckedFuture<Void, RestApiException> insertChange() throws IOException {
rp.getRevWalk().parseBody(commit);
final Thread caller = Thread.currentThread();
ListenableFuture<Void> future = changeUpdateExector.submit(
requestScopePropagator.wrap(new Callable<Void>() {
@Override
public Void call() throws OrmException, IOException,
ResourceConflictException {
if (caller == Thread.currentThread()) {
insertChange(db);
} else {
try (ReviewDb db = schemaFactory.open()) {
insertChange(db);
}
}
insertChangeImpl();
synchronized (newProgress) {
newProgress.update(1);
}
@@ -1748,7 +1741,7 @@ public class ReceiveCommits {
return Futures.makeChecked(future, INSERT_EXCEPTION);
}
private void insertChange(ReviewDb db) throws OrmException, IOException,
private void insertChangeImpl() throws OrmException, IOException,
ResourceConflictException {
final PatchSet ps = ins.setGroups(groups).getPatchSet();
final Account.Id me = currentUser.getAccountId();
@@ -1762,17 +1755,11 @@ public class ReceiveCommits {
}
recipients.add(getRecipientsFromFooters(accountResolver, ps, footerLines));
recipients.remove(me);
ChangeMessage msg =
new ChangeMessage(new ChangeMessage.Key(change.getId(),
ChangeUtil.messageUUID(db)), me, ps.getCreatedOn(), ps.getId());
msg.setMessage("Uploaded patch set " + ps.getPatchSetId() + ".");
ins
.setReviewers(recipients.getReviewers())
.setExtraCC(recipients.getCcOnly())
.setApprovals(approvals)
.setMessage(msg)
.setMessage("Uploaded patch set " + ps.getPatchSetId() + ".")
.setRequestScopePropagator(requestScopePropagator)
.setSendMail(true)
.insert();