use of org.eclipse.jgit.lib.TextProgressMonitor 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;
}
use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class GarbageCollection method run.
public GarbageCollectionResult run(List<Project.NameKey> projectNames, boolean aggressive, PrintWriter writer) {
GarbageCollectionResult result = new GarbageCollectionResult();
Set<Project.NameKey> projectsToGc = gcQueue.addAll(projectNames);
for (Project.NameKey projectName : Sets.difference(Sets.newHashSet(projectNames), projectsToGc)) {
result.addError(new GarbageCollectionResult.Error(GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED, projectName));
}
for (Project.NameKey p : projectsToGc) {
try (Repository repo = repoManager.openRepository(p)) {
logGcConfiguration(p, repo, aggressive);
print(writer, "collecting garbage for \"" + p + "\":\n");
GarbageCollectCommand gc = Git.wrap(repo).gc();
gc.setAggressive(aggressive);
logGcInfo(p, "before:", gc.getStatistics());
gc.setProgressMonitor(writer != null ? new TextProgressMonitor(writer) : NullProgressMonitor.INSTANCE);
Properties statistics = gc.call();
logGcInfo(p, "after: ", statistics);
print(writer, "done.\n\n");
fire(p, statistics);
} catch (RepositoryNotFoundException e) {
logGcError(writer, p, e);
result.addError(new GarbageCollectionResult.Error(GarbageCollectionResult.Error.Type.REPOSITORY_NOT_FOUND, p));
} catch (Exception e) {
logGcError(writer, p, e);
result.addError(new GarbageCollectionResult.Error(GarbageCollectionResult.Error.Type.GC_FAILED, p));
} finally {
gcQueue.gcFinished(p);
}
}
return result;
}
Aggregations