Lazily load the changes byKey map in autoCloseChanges
When a large number of commits are merged in from an upstream Git repository that does not use Gerrit there may be no Change-Id lines found in the revision range being traversed. Avoid scanning the database to query out open changes until at least one commit is found that has a Change-Id footer. Change-Id: I91d2647691daef9755ade2bfbf0d3c25eefd02db
This commit is contained in:
@@ -2386,7 +2386,7 @@ public class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final SetMultimap<ObjectId, Ref> byCommit = changeRefsById();
|
final SetMultimap<ObjectId, Ref> byCommit = changeRefsById();
|
||||||
final Map<Change.Key, Change.Id> byKey = openChangesByKey(branch);
|
Map<Change.Key, Change.Id> byKey = null;
|
||||||
final List<ReplaceRequest> toClose = new ArrayList<>();
|
final List<ReplaceRequest> toClose = new ArrayList<>();
|
||||||
for (RevCommit c; (c = rw.next()) != null;) {
|
for (RevCommit c; (c = rw.next()) != null;) {
|
||||||
rw.parseBody(c);
|
rw.parseBody(c);
|
||||||
@@ -2401,6 +2401,10 @@ public class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final String changeId : c.getFooterLines(CHANGE_ID)) {
|
for (final String changeId : c.getFooterLines(CHANGE_ID)) {
|
||||||
|
if (byKey == null) {
|
||||||
|
byKey = openChangesByKey(branch);
|
||||||
|
}
|
||||||
|
|
||||||
final Change.Id onto = byKey.get(new Change.Key(changeId.trim()));
|
final Change.Id onto = byKey.get(new Change.Key(changeId.trim()));
|
||||||
if (onto != null) {
|
if (onto != null) {
|
||||||
final ReplaceRequest req = new ReplaceRequest(onto, c, cmd, false);
|
final ReplaceRequest req = new ReplaceRequest(onto, c, cmd, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user