Merge "Update patch status before skipping duplicate emails" into stable-2.6

This commit is contained in:
Shawn Pearce
2013-11-18 16:22:44 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 13 deletions

View File

@@ -126,7 +126,6 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
// If the merge was attempted and it failed the system usually // If the merge was attempted and it failed the system usually
// writes a comment as a ChangeMessage and sets status to NEW. // writes a comment as a ChangeMessage and sets status to NEW.
// Find the relevant message and report that as the conflict. // Find the relevant message and report that as the conflict.
final Timestamp before = rsrc.getChange().getLastUpdatedOn();
ChangeMessage msg = Iterables.getFirst(Iterables.filter( ChangeMessage msg = Iterables.getFirst(Iterables.filter(
Lists.reverse(dbProvider.get().changeMessages() Lists.reverse(dbProvider.get().changeMessages()
.byChange(change.getId()) .byChange(change.getId())
@@ -134,8 +133,7 @@ public class Submit implements RestModifyView<RevisionResource, Input> {
new Predicate<ChangeMessage>() { new Predicate<ChangeMessage>() {
@Override @Override
public boolean apply(ChangeMessage input) { public boolean apply(ChangeMessage input) {
return input.getAuthor() == null return input.getAuthor() == null;
&& input.getWrittenOn().getTime() >= before.getTime();
} }
}), null); }), null);
if (msg != null) { if (msg != null) {

View File

@@ -1045,16 +1045,6 @@ public class MergeOp {
private void sendMergeFail(final Change c, final ChangeMessage msg, private void sendMergeFail(final Change c, final ChangeMessage msg,
final boolean makeNew) { 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) { if (makeNew) {
try { try {
db.changes().atomicUpdate(c.getId(), new AtomicUpdate<Change>() { 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; PatchSetApproval submitter = null;
try { try {
submitter = getSubmitter(db, c.currentPatchSetId()); submitter = getSubmitter(db, c.currentPatchSetId());