Don't abbreviate duplicate merge failed messages
We are now only sending duplicate change emails once a day, so repeating ourselves that often isn't too noisy. Also, isAlreadySent and isDuplicate were repeating the relatively expensive operation of listing all messages for a change, and there's no need to do that work twice. Change-Id: Ib92e584d9290df43632374f34327a153192ad14a
This commit is contained in:
@@ -805,11 +805,8 @@ public class MergeOp {
|
|||||||
// dependencies are also submitted. Perhaps the user just
|
// dependencies are also submitted. Perhaps the user just
|
||||||
// forgot to submit those.
|
// forgot to submit those.
|
||||||
//
|
//
|
||||||
String txt =
|
|
||||||
"Change could not be merged because of a missing dependency.";
|
|
||||||
if (!isAlreadySent(c, txt)) {
|
|
||||||
StringBuilder m = new StringBuilder();
|
StringBuilder m = new StringBuilder();
|
||||||
m.append(txt);
|
m.append("Change could not be merged because of a missing dependency.");
|
||||||
m.append("\n");
|
m.append("\n");
|
||||||
|
|
||||||
m.append("\n");
|
m.append("\n");
|
||||||
@@ -821,9 +818,7 @@ public class MergeOp {
|
|||||||
m.append(missingCommit.change.getKey().get());
|
m.append(missingCommit.change.getKey().get());
|
||||||
m.append("\n");
|
m.append("\n");
|
||||||
}
|
}
|
||||||
txt = m.toString();
|
capable = new Capable(m.toString());
|
||||||
}
|
|
||||||
capable = new Capable(txt);
|
|
||||||
} else {
|
} else {
|
||||||
// It is impossible to submit this change as-is. The author
|
// It is impossible to submit this change as-is. The author
|
||||||
// needs to rebase it in order to work around the missing
|
// needs to rebase it in order to work around the missing
|
||||||
@@ -874,30 +869,6 @@ public class MergeOp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAlreadySent(final Change c, final String prefix) {
|
|
||||||
try {
|
|
||||||
final List<ChangeMessage> msgList =
|
|
||||||
db.changeMessages().byChange(c.getId()).toList();
|
|
||||||
if (msgList.size() > 0) {
|
|
||||||
final ChangeMessage last = msgList.get(msgList.size() - 1);
|
|
||||||
if (last.getAuthor() == null && last.getMessage().startsWith(prefix)) {
|
|
||||||
// The last message was written by us, and it said this
|
|
||||||
// same message already. Its unlikely anything has changed
|
|
||||||
// that would cause us to need to repeat ourselves.
|
|
||||||
//
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The last message was not sent by us, or doesn't match the text
|
|
||||||
// we are about to send.
|
|
||||||
//
|
|
||||||
return false;
|
|
||||||
} catch (OrmException e) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ChangeMessage message(final Change c, final String body) {
|
private ChangeMessage message(final Change c, final String body) {
|
||||||
final String uuid;
|
final String uuid;
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user