ChangeNotesParser: Don't open the repository
This was left over from long before passing in a previously opened RevWalk; the repo that is opened is never used. With this change, ChangeNotesParser no longer needs to be AutoCloseable either. Change-Id: I46f2ddb6e81105635b7384012e33479ae4a2fd24
This commit is contained in:
@@ -17,7 +17,6 @@ package com.google.gerrit.server.notedb;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.notedb.ChangeNotesCommit.ChangeNotesRevWalk;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
@@ -482,9 +481,7 @@ public class ChangeNotesParserTest extends AbstractChangeNotesTest {
|
||||
}
|
||||
|
||||
private void assertParseSucceeds(RevCommit commit) throws Exception {
|
||||
try (ChangeNotesParser parser = newParser(commit)) {
|
||||
parser.parseAll();
|
||||
}
|
||||
newParser(commit).parseAll();
|
||||
}
|
||||
|
||||
private void assertParseFails(String body) throws Exception {
|
||||
@@ -492,8 +489,8 @@ public class ChangeNotesParserTest extends AbstractChangeNotesTest {
|
||||
}
|
||||
|
||||
private void assertParseFails(RevCommit commit) throws Exception {
|
||||
try (ChangeNotesParser parser = newParser(commit)) {
|
||||
parser.parseAll();
|
||||
try {
|
||||
newParser(commit).parseAll();
|
||||
fail("Expected parse to fail:\n" + commit.getFullMessage());
|
||||
} catch (ConfigInvalidException e) {
|
||||
// Expected
|
||||
@@ -501,8 +498,7 @@ public class ChangeNotesParserTest extends AbstractChangeNotesTest {
|
||||
}
|
||||
|
||||
private ChangeNotesParser newParser(ObjectId tip) throws Exception {
|
||||
Change c = newChange();
|
||||
return new ChangeNotesParser(c.getProject(), c.getId(), tip, walk,
|
||||
repoManager, noteUtil, args.metrics);
|
||||
return new ChangeNotesParser(
|
||||
newChange().getId(), tip, walk, noteUtil, args.metrics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,27 +1018,23 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
|
||||
assertThat(commitWithComments).isNotNull();
|
||||
|
||||
try (ChangeNotesRevWalk rw = ChangeNotesCommit.newRevWalk(repo)) {
|
||||
try (ChangeNotesParser notesWithComments = new ChangeNotesParser(
|
||||
project, c.getId(), commitWithComments.copy(), rw, repoManager,
|
||||
noteUtil, args.metrics)) {
|
||||
notesWithComments.parseAll();
|
||||
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals1 =
|
||||
notesWithComments.buildApprovals();
|
||||
assertThat(approvals1).isEmpty();
|
||||
assertThat(notesWithComments.comments).hasSize(1);
|
||||
}
|
||||
ChangeNotesParser notesWithComments = new ChangeNotesParser(
|
||||
c.getId(), commitWithComments.copy(), rw, noteUtil, args.metrics);
|
||||
notesWithComments.parseAll();
|
||||
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals1 =
|
||||
notesWithComments.buildApprovals();
|
||||
assertThat(approvals1).isEmpty();
|
||||
assertThat(notesWithComments.comments).hasSize(1);
|
||||
}
|
||||
|
||||
try (ChangeNotesRevWalk rw = ChangeNotesCommit.newRevWalk(repo)) {
|
||||
try (ChangeNotesParser notesWithApprovals = new ChangeNotesParser(project,
|
||||
c.getId(), commitWithApprovals.copy(), rw, repoManager,
|
||||
noteUtil, args.metrics)) {
|
||||
notesWithApprovals.parseAll();
|
||||
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals2 =
|
||||
notesWithApprovals.buildApprovals();
|
||||
assertThat(approvals2).hasSize(1);
|
||||
assertThat(notesWithApprovals.comments).hasSize(1);
|
||||
}
|
||||
ChangeNotesParser notesWithApprovals = new ChangeNotesParser(c.getId(),
|
||||
commitWithApprovals.copy(), rw, noteUtil, args.metrics);
|
||||
notesWithApprovals.parseAll();
|
||||
ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals2 =
|
||||
notesWithApprovals.buildApprovals();
|
||||
assertThat(approvals2).hasSize(1);
|
||||
assertThat(notesWithApprovals.comments).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user