Minor refactor of updatedChange steps in ChangeUtil
Use a common function to set the ChangeMessage and update the approvals cache after updating a Change. Change-Id: I019ce22f819e6d46acc5be4d2ed78b7cccb54ae0
This commit is contained in:
@@ -246,19 +246,8 @@ public class ChangeUtil {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updatedChange == null) {
|
updatedChange(db, updatedChange, cmsg,
|
||||||
throw new InvalidChangeOperationException(
|
"Change is no longer open or patchset is not latest");
|
||||||
"Change is no longer open 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);
|
|
||||||
|
|
||||||
// Email the reviewers
|
// Email the reviewers
|
||||||
final AbandonedSender cm = abandonedSenderFactory.create(updatedChange);
|
final AbandonedSender cm = abandonedSenderFactory.create(updatedChange);
|
||||||
@@ -408,19 +397,8 @@ public class ChangeUtil {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updatedChange == null) {
|
updatedChange(db, updatedChange, cmsg,
|
||||||
throw new InvalidChangeOperationException(
|
"Change is not abandoned or patchset is not latest");
|
||||||
"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);
|
|
||||||
|
|
||||||
// Email the reviewers
|
// Email the reviewers
|
||||||
final AbandonedSender cm = abandonedSenderFactory.create(updatedChange);
|
final AbandonedSender cm = abandonedSenderFactory.create(updatedChange);
|
||||||
@@ -431,6 +409,23 @@ public class ChangeUtil {
|
|||||||
hooks.doChangeRestoreHook(updatedChange, user.getAccount(), message);
|
hooks.doChangeRestoreHook(updatedChange, user.getAccount(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updatedChange(final ReviewDb db, final Change change,
|
||||||
|
final ChangeMessage cmsg, final String err) throws NoSuchChangeException,
|
||||||
|
InvalidChangeOperationException, OrmException {
|
||||||
|
if (change == null) {
|
||||||
|
throw new InvalidChangeOperationException(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
db.changeMessages().insert(Collections.singleton(cmsg));
|
||||||
|
|
||||||
|
final List<PatchSetApproval> approvals =
|
||||||
|
db.patchSetApprovals().byChange(change.getId()).toList();
|
||||||
|
for (PatchSetApproval a : approvals) {
|
||||||
|
a.cache(change);
|
||||||
|
}
|
||||||
|
db.patchSetApprovals().update(approvals);
|
||||||
|
}
|
||||||
|
|
||||||
public static String sortKey(long lastUpdated, int id){
|
public static String sortKey(long lastUpdated, int id){
|
||||||
// The encoding uses minutes since Wed Oct 1 00:00:00 2008 UTC.
|
// The encoding uses minutes since Wed Oct 1 00:00:00 2008 UTC.
|
||||||
// We overrun approximately 4,085 years later, so ~6093.
|
// We overrun approximately 4,085 years later, so ~6093.
|
||||||
|
Reference in New Issue
Block a user