Search in sources :

Example 1 with NoPatchSetsException

use of com.google.gerrit.server.notedb.rebuild.ChangeRebuilder.NoPatchSetsException 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;
}
Also used : ChainedReceiveCommands(com.google.gerrit.server.update.ChainedReceiveCommands) NoteDbUpdateManager(com.google.gerrit.server.notedb.NoteDbUpdateManager) Change(com.google.gerrit.reviewdb.client.Change) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) RevWalk(org.eclipse.jgit.revwalk.RevWalk) BufferedWriter(java.io.BufferedWriter) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) NullProgressMonitor(org.eclipse.jgit.lib.NullProgressMonitor) ProgressMonitor(org.eclipse.jgit.lib.ProgressMonitor) ObjectInserter(org.eclipse.jgit.lib.ObjectInserter) NoPatchSetsException(com.google.gerrit.server.notedb.rebuild.ChangeRebuilder.NoPatchSetsException) OutputStreamWriter(java.io.OutputStreamWriter) ObjectReader(org.eclipse.jgit.lib.ObjectReader) PrintWriter(java.io.PrintWriter)

Aggregations

Change (com.google.gerrit.reviewdb.client.Change)1 NoteDbUpdateManager (com.google.gerrit.server.notedb.NoteDbUpdateManager)1 NoPatchSetsException (com.google.gerrit.server.notedb.rebuild.ChangeRebuilder.NoPatchSetsException)1 ChainedReceiveCommands (com.google.gerrit.server.update.ChainedReceiveCommands)1 BufferedWriter (java.io.BufferedWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 NullProgressMonitor (org.eclipse.jgit.lib.NullProgressMonitor)1 ObjectInserter (org.eclipse.jgit.lib.ObjectInserter)1 ObjectReader (org.eclipse.jgit.lib.ObjectReader)1 ProgressMonitor (org.eclipse.jgit.lib.ProgressMonitor)1 TextProgressMonitor (org.eclipse.jgit.lib.TextProgressMonitor)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1