Search in sources :

Example 1 with RevWalkException

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();
        }
    }
}
Also used : RevTag(org.eclipse.jgit.revwalk.RevTag) RevObject(org.eclipse.jgit.revwalk.RevObject) OutputStream(java.io.OutputStream) RevWalkException(org.eclipse.jgit.errors.RevWalkException) Repository(org.eclipse.jgit.lib.Repository) RevObject(org.eclipse.jgit.revwalk.RevObject) Map(java.util.Map) Writer(java.io.Writer)

Aggregations

OutputStream (java.io.OutputStream)1 Writer (java.io.Writer)1 Map (java.util.Map)1 RevWalkException (org.eclipse.jgit.errors.RevWalkException)1 Repository (org.eclipse.jgit.lib.Repository)1 RevObject (org.eclipse.jgit.revwalk.RevObject)1 RevTag (org.eclipse.jgit.revwalk.RevTag)1