Update patch status before skipping duplicate emails
isDuplicate() was added in 2.6 to prevent sending duplicate emails on merge failures, however this causes the makeNew() flag to be ignored if there's already a duplicate message. This prevents the duplicate email, but keeps the change from getting stuck in the merge queue. Bug: Issue 2244 Change-Id: Ib0b9b10d40256d9b4bfdbba79aab23207987e7f4
This commit is contained in:
@@ -126,7 +126,6 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
|
||||
// If the merge was attempted and it failed the system usually
|
||||
// writes a comment as a ChangeMessage and sets status to NEW.
|
||||
// Find the relevant message and report that as the conflict.
|
||||
final Timestamp before = rsrc.getChange().getLastUpdatedOn();
|
||||
ChangeMessage msg = Iterables.getFirst(Iterables.filter(
|
||||
Lists.reverse(dbProvider.get().changeMessages()
|
||||
.byChange(change.getId())
|
||||
@@ -134,8 +133,7 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
|
||||
new Predicate<ChangeMessage>() {
|
||||
@Override
|
||||
public boolean apply(ChangeMessage input) {
|
||||
return input.getAuthor() == null
|
||||
&& input.getWrittenOn().getTime() >= before.getTime();
|
||||
return input.getAuthor() == null;
|
||||
}
|
||||
}), null);
|
||||
if (msg != null) {
|
||||
|
||||
@@ -1045,16 +1045,6 @@ public class MergeOp {
|
||||
|
||||
private void sendMergeFail(final Change c, final ChangeMessage msg,
|
||||
final boolean makeNew) {
|
||||
if (isDuplicate(msg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
db.changeMessages().insert(Collections.singleton(msg));
|
||||
} catch (OrmException err) {
|
||||
log.warn("Cannot record merge failure message", err);
|
||||
}
|
||||
|
||||
if (makeNew) {
|
||||
try {
|
||||
db.changes().atomicUpdate(c.getId(), new AtomicUpdate<Change>() {
|
||||
@@ -1079,6 +1069,16 @@ public class MergeOp {
|
||||
}
|
||||
}
|
||||
|
||||
if (isDuplicate(msg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
db.changeMessages().insert(Collections.singleton(msg));
|
||||
} catch (OrmException err) {
|
||||
log.warn("Cannot record merge failure message", err);
|
||||
}
|
||||
|
||||
PatchSetApproval submitter = null;
|
||||
try {
|
||||
submitter = getSubmitter(db, c.currentPatchSetId());
|
||||
|
||||
Reference in New Issue
Block a user