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:
Shawn Pearce
2014-10-16 15:25:08 -07:00
parent 792f8c170f
commit f07f0e6f4e

View File

@@ -2386,7 +2386,7 @@ public class ReceiveCommits {
}
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<>();
for (RevCommit c; (c = rw.next()) != null;) {
rw.parseBody(c);
@@ -2401,6 +2401,10 @@ public class ReceiveCommits {
}
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()));
if (onto != null) {
final ReplaceRequest req = new ReplaceRequest(onto, c, cmd, false);