Avoid validating valid commits two times in ReceiveCommits.
There was at least one case where valid commits were validated two times. For example, when a new patch set for an existing change was pushed, the first validation for that commit was done (early) from the selectNewChanges method and the second validation of the same commit was done from the inner ReplaceRequest class. The first (early) validation was obviously done for performance reasons to fail fast for invalid commits. However, as a side effect, valid commits were validated two times. Cache already validated valid commits and don't validate them again for the same ReceiveCommits command. Change-Id: I221284a27ee475f84c1726b4d50553b755d2b4fe
This commit is contained in:
parent
dbc2f75dc9
commit
98c89249c5
@ -274,6 +274,7 @@ public class ReceiveCommits {
|
||||
new HashMap<Change.Id, ReplaceRequest>();
|
||||
private final Map<RevCommit, ReplaceRequest> replaceByCommit =
|
||||
new HashMap<RevCommit, ReplaceRequest>();
|
||||
private final Set<RevCommit> validCommits = new HashSet<RevCommit>();
|
||||
|
||||
private Map<ObjectId, Ref> refsById;
|
||||
private Map<String, Ref> allRefs;
|
||||
@ -1973,6 +1974,10 @@ public class ReceiveCommits {
|
||||
private boolean validCommit(final RefControl ctl, final ReceiveCommand cmd,
|
||||
final RevCommit c) throws MissingObjectException, IOException {
|
||||
|
||||
if (validCommits.contains(c)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CommitReceivedEvent receiveEvent =
|
||||
new CommitReceivedEvent(cmd, project, ctl.getRefName(), c, currentUser);
|
||||
CommitValidators commitValidators =
|
||||
@ -1985,6 +1990,7 @@ public class ReceiveCommits {
|
||||
reject(cmd, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
validCommits.add(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user