Merge branch 'stable-2.13'
* stable-2.13: Fix to reindex a change via SSH: get from DB/Notes instead of Lucene Update git submodules Fix Postgresql JDBC driver leaking memory Fix Schema_127 for mysql on case-sensitive FS Update git submodules Change-Id: Ida6a895ccb8cab2c68bb0cdb83fe4d076f2b007c
This commit is contained in:
@@ -45,18 +45,18 @@ public class Schema_127 extends SchemaVersion {
|
||||
H2AccountPatchReviewStore.createTableIfNotExists(url);
|
||||
try (Connection con = DriverManager.getConnection(url);
|
||||
PreparedStatement stmt =
|
||||
con.prepareStatement("INSERT INTO ACCOUNT_PATCH_REVIEWS "
|
||||
+ "(ACCOUNT_ID, CHANGE_ID, PATCH_SET_ID, FILE_NAME) VALUES "
|
||||
con.prepareStatement("INSERT INTO account_patch_reviews "
|
||||
+ "(account_id, change_id, patch_set_id, file_name) VALUES "
|
||||
+ "(?, ?, ?, ?)")) {
|
||||
int batchCount = 0;
|
||||
|
||||
try (Statement s = newStatement(db);
|
||||
ResultSet rs = s.executeQuery("SELECT * from ACCOUNT_PATCH_REVIEWS")) {
|
||||
ResultSet rs = s.executeQuery("SELECT * from account_patch_reviews")) {
|
||||
while (rs.next()) {
|
||||
stmt.setInt(1, rs.getInt("ACCOUNT_ID"));
|
||||
stmt.setInt(2, rs.getInt("CHANGE_ID"));
|
||||
stmt.setInt(3, rs.getInt("PATCH_SET_ID"));
|
||||
stmt.setString(4, rs.getString("FILE_NAME"));
|
||||
stmt.setInt(1, rs.getInt("account_id"));
|
||||
stmt.setInt(2, rs.getInt("change_id"));
|
||||
stmt.setInt(3, rs.getInt("patch_set_id"));
|
||||
stmt.setString(4, rs.getString("file_name"));
|
||||
stmt.addBatch();
|
||||
batchCount++;
|
||||
if (batchCount >= MAX_BATCH_SIZE) {
|
||||
|
@@ -14,6 +14,10 @@
|
||||
|
||||
package com.google.gerrit.sshd;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
@@ -21,13 +25,16 @@ import com.google.gerrit.server.ChangeFinder;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.change.ChangesCollection;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gerrit.sshd.BaseCommand.UnloggedFailure;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -36,16 +43,22 @@ public class ChangeArgumentParser {
|
||||
private final ChangesCollection changesCollection;
|
||||
private final ChangeFinder changeFinder;
|
||||
private final ReviewDb db;
|
||||
private final ChangeNotes.Factory changeNotesFactory;
|
||||
private final ChangeControl.GenericFactory changeControlFactory;
|
||||
|
||||
@Inject
|
||||
ChangeArgumentParser(CurrentUser currentUser,
|
||||
ChangesCollection changesCollection,
|
||||
ChangeFinder changeFinder,
|
||||
ReviewDb db) {
|
||||
ReviewDb db,
|
||||
ChangeNotes.Factory changeNotesFactory,
|
||||
ChangeControl.GenericFactory changeControlFactory) {
|
||||
this.currentUser = currentUser;
|
||||
this.changesCollection = changesCollection;
|
||||
this.changeFinder = changeFinder;
|
||||
this.db = db;
|
||||
this.changeNotesFactory = changeNotesFactory;
|
||||
this.changeControlFactory = changeControlFactory;
|
||||
}
|
||||
|
||||
public void addChange(String id, Map<Change.Id, ChangeResource> changes)
|
||||
@@ -55,7 +68,16 @@ public class ChangeArgumentParser {
|
||||
|
||||
public void addChange(String id, Map<Change.Id, ChangeResource> changes,
|
||||
ProjectControl projectControl) throws UnloggedFailure, OrmException {
|
||||
List<ChangeControl> matched = changeFinder.find(id, currentUser);
|
||||
addChange(id, changes, projectControl, true);
|
||||
}
|
||||
|
||||
public void addChange(String id, Map<Change.Id, ChangeResource> changes,
|
||||
ProjectControl projectControl, boolean useIndex) throws UnloggedFailure,
|
||||
OrmException {
|
||||
List<ChangeControl> matched =
|
||||
useIndex ?
|
||||
changeFinder.find(id, currentUser) :
|
||||
changeFromNotesFactory(id, currentUser);
|
||||
List<ChangeControl> toAdd = new ArrayList<>(changes.size());
|
||||
for (ChangeControl ctl : matched) {
|
||||
if (!changes.containsKey(ctl.getId())
|
||||
@@ -74,6 +96,27 @@ public class ChangeArgumentParser {
|
||||
changes.put(ctl.getId(), changesCollection.parse(ctl));
|
||||
}
|
||||
|
||||
private List<ChangeControl> changeFromNotesFactory(String id,
|
||||
final CurrentUser currentUser) throws OrmException {
|
||||
List<ChangeNotes> changes =
|
||||
changeNotesFactory.create(db, Arrays.asList(Change.Id.parse(id)));
|
||||
return FluentIterable.from(changes)
|
||||
.transform(new Function<ChangeNotes, ChangeControl>() {
|
||||
@Override
|
||||
public ChangeControl apply(ChangeNotes changeNote) {
|
||||
return controlForChange(changeNote, currentUser);
|
||||
}
|
||||
}).filter(Predicates.notNull()).toList();
|
||||
}
|
||||
|
||||
private ChangeControl controlForChange(ChangeNotes change, CurrentUser user) {
|
||||
try {
|
||||
return changeControlFactory.controlFor(change, user);
|
||||
} catch (NoSuchChangeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean inProject(ProjectControl projectControl, Project project) {
|
||||
if (projectControl != null) {
|
||||
return projectControl.getProject().getNameKey().equals(project.getNameKey());
|
||||
|
@@ -42,7 +42,7 @@ final class IndexChangesCommand extends SshCommand {
|
||||
usage = "changes to index")
|
||||
void addChange(String token) {
|
||||
try {
|
||||
changeArgumentParser.addChange(token, changes);
|
||||
changeArgumentParser.addChange(token, changes, null, false);
|
||||
} catch (UnloggedFailure e) {
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
} catch (OrmException e) {
|
||||
|
4
lib/BUCK
4
lib/BUCK
@@ -203,8 +203,8 @@ maven_jar(
|
||||
|
||||
maven_jar(
|
||||
name = 'postgresql',
|
||||
id = 'postgresql:postgresql:9.1-901-1.jdbc4',
|
||||
sha1 = '9bfabe48876ec38f6cbaa6931bad05c64a9ea942',
|
||||
id = 'org.postgresql:postgresql:9.4.1211.jre7',
|
||||
sha1 = '56b01e9e667f408818a6ef06a89598dbab80687d',
|
||||
license = 'postgresql',
|
||||
attach_source = False,
|
||||
)
|
||||
|
Reference in New Issue
Block a user