use of org.eclipse.jgit.errors.RevWalkException in project gitiles by GerritCodeReview.
the class LogServlet method doGetHtml.
@Override
protected void doGetHtml(HttpServletRequest req, HttpServletResponse res) throws IOException {
Repository repo = ServletUtils.getRepository(req);
GitilesView view = getView(req, repo);
Paginator paginator = null;
try {
GitilesAccess access = getAccess(req);
paginator = newPaginator(repo, view, access);
if (paginator == null) {
res.setStatus(SC_NOT_FOUND);
return;
}
DateFormatter df = new DateFormatter(access, Format.DEFAULT);
// Allow the user to select a logView variant with the "pretty" param.
String pretty = Iterables.getFirst(view.getParameters().get(PRETTY_PARAM), "default");
Map<String, Object> data = Maps.newHashMapWithExpectedSize(2);
if (!view.getRevision().nameIsId()) {
List<Map<String, Object>> tags = Lists.newArrayListWithExpectedSize(1);
for (RevObject o : RevisionServlet.listObjects(paginator.getWalk(), view.getRevision())) {
if (o instanceof RevTag) {
tags.add(new TagSoyData(linkifier, req).toSoyData((RevTag) o, df));
}
}
if (!tags.isEmpty()) {
data.put("tags", tags);
}
}
String title = "Log - ";
if (view.getOldRevision() != Revision.NULL) {
title += view.getRevisionRange();
} else {
title += view.getRevision().getName();
}
data.put("title", title);
try (OutputStream out = startRenderStreamingHtml(req, res, "gitiles.logDetail", data)) {
Writer w = newWriter(out, res);
new LogSoyData(req, access, pretty).renderStreaming(paginator, null, renderer, w, df);
w.flush();
}
} catch (RevWalkException e) {
log.warn("Error in rev walk", e);
res.setStatus(SC_INTERNAL_SERVER_ERROR);
return;
} finally {
if (paginator != null) {
paginator.getWalk().close();
}
}
}
Aggregations