use of com.google.gerrit.server.update.ChainedReceiveCommands in project gerrit by GerritCodeReview.
the class NoteDbUpdateManager method openRepo.
private OpenRepo openRepo(Project.NameKey p) throws IOException {
// Closed by OpenRepo#close.
Repository repo = repoManager.openRepository(p);
// Closed by OpenRepo#close.
ObjectInserter ins = repo.newObjectInserter();
// Not closed by OpenRepo#close.
ObjectReader reader = ins.newReader();
try (RevWalk rw = new RevWalk(reader)) {
// Doesn't escape OpenRepo constructor.
return new OpenRepo(repo, rw, ins, new ChainedReceiveCommands(repo), true) {
@Override
public void close() {
reader.close();
super.close();
}
};
}
}
use of com.google.gerrit.server.update.ChainedReceiveCommands in project gerrit by GerritCodeReview.
the class RebuildNoteDb method rebuildProject.
private boolean rebuildProject(ReviewDb db, ImmutableListMultimap<Project.NameKey, Change.Id> allChanges, Project.NameKey project, Repository allUsersRepo) throws IOException, OrmException {
checkArgument(allChanges.containsKey(project));
boolean ok = true;
ProgressMonitor pm = new TextProgressMonitor(new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, UTF_8))));
pm.beginTask(FormatUtil.elide(project.get(), 50), allChanges.get(project).size());
try (NoteDbUpdateManager manager = updateManagerFactory.create(project);
ObjectInserter allUsersInserter = allUsersRepo.newObjectInserter();
ObjectReader reader = allUsersInserter.newReader();
RevWalk allUsersRw = new RevWalk(reader)) {
manager.setAllUsersRepo(allUsersRepo, allUsersRw, allUsersInserter, new ChainedReceiveCommands(allUsersRepo));
for (Change.Id changeId : allChanges.get(project)) {
try {
rebuilder.buildUpdates(manager, bundleReader.fromReviewDb(db, changeId));
} catch (NoPatchSetsException e) {
log.warn(e.getMessage());
} catch (Throwable t) {
log.error("Failed to rebuild change " + changeId, t);
ok = false;
}
pm.update(1);
}
manager.execute();
} finally {
pm.endTask();
}
return ok;
}
Aggregations