Source:
public static void restore(final PatchSet.Id patchSetId, final IdentifiedUser user, final String message, final ReviewDb db, final AbandonedSender.Factory abandonedSenderFactory, final ChangeHookRunner hooks) throws NoSuchChangeException, InvalidChangeOperationException, EmailException, OrmException { final Change.Id changeId = patchSetId.getParentKey(); final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(changeId, ChangeUtil .messageUUID(db)), user.getAccountId()); final StringBuilder msgBuf = new StringBuilder("Patch Set " + patchSetId.get() + ": Restored"); if (message != null && message.length() > 0) { msgBuf.append("\n\n"); msgBuf.append(message); } cmsg.setMessage(msgBuf.toString()); final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { if (change.getStatus() == Change.Status.ABANDONED && change.currentPatchSetId().equals(patchSetId)) { change.setStatus(Change.Status.NEW); ChangeUtil.updated(change); return change; } else { return null; } } }); if (updatedChange == null) { throw new InvalidChangeOperationException( "Change is not abandonned or patchset is not latest"); } db.changeMessages().insert(Collections.singleton(cmsg)); final List<PatchSetApproval> approvals = db.patchSetApprovals().byChange(changeId).toList(); for (PatchSetApproval a : approvals) { a.cache(updatedChange); } db.patchSetApprovals().update(approvals); final AbandonedSender cm = abandonedSenderFactory.create(updatedChange); cm.setFrom(user.getAccountId()); cm.setChangeMessage(cmsg); cm.send(); hooks.doChangeRestoreHook(updatedChange, user.getAccount(), message); }

Target:
public static void restore(final PatchSet.Id patchSetId, final IdentifiedUser user, final String message, final ReviewDb db, final AbandonedSender.Factory abandonedSenderFactory, final ChangeHookRunner hooks) throws NoSuchChangeException, InvalidChangeOperationException, EmailException, OrmException { final Change.Id changeId = patchSetId.getParentKey(); final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(changeId, ChangeUtil .messageUUID(db)), user.getAccountId()); final StringBuilder msgBuf = new StringBuilder("Patch Set " + patchSetId.get() + ": Restored"); if (message != null && message.length() > 0) { msgBuf.append("\n\n"); msgBuf.append(message); } cmsg.setMessage(msgBuf.toString()); final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { if (change.getStatus() == Change.Status.ABANDONED && change.currentPatchSetId().equals(patchSetId)) { change.setStatus(Change.Status.NEW); ChangeUtil.updated(change); return change; } else { return null; } } }); if (updatedChange == null) { throw new InvalidChangeOperationException( "Change is not abandoned or patchset is not latest"); } db.changeMessages().insert(Collections.singleton(cmsg)); final List<PatchSetApproval> approvals = db.patchSetApprovals().byChange(changeId).toList(); for (PatchSetApproval a : approvals) { a.cache(updatedChange); } db.patchSetApprovals().update(approvals); final AbandonedSender cm = abandonedSenderFactory.create(updatedChange); cm.setFrom(user.getAccountId()); cm.setChangeMessage(cmsg); cm.send(); hooks.doChangeRestoreHook(updatedChange, user.getAccount(), message); }