Fix approval copying when labels are set on push

A primary key error was occurring whenever a PatchSet was pushed
with a label overriding a sticky approval from a prior PatchSet.
The cause is that when changes are read from NoteDb, ApprovalCopier
doesn't have access to these new approvals.

This change adds an optional parameter to ApprovalCopier#copy,
dontCopy, which is used to block copying of approvals of the
given (account, label) pairs from any prior PatchSets.

Change-Id: I417deba5b42e38f498c879696998651597535659
This commit is contained in:
Logan Hanks
2016-08-17 16:48:00 -07:00
parent 0ca37dc55b
commit 9f07939a76
4 changed files with 96 additions and 24 deletions

View File

@@ -783,6 +783,23 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
pushWithReviewerInFooter("Notauser", null);
}
@Test
public void pushNewPatchsetOverridingStickyLabel() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
LabelType codeReview = Util.codeReview();
codeReview.setCopyMaxScore(true);
cfg.getLabelSections().put(codeReview.getName(), codeReview);
saveProjectConfig(cfg);
PushOneCommit.Result r = pushTo("refs/for/master%l=Code-Review+2");
r.assertOkStatus();
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master%l=Code-Review+1");
r.assertOkStatus();
}
private void pushWithReviewerInFooter(String nameEmail,
TestAccount expectedReviewer) throws Exception {
int n = 5;