%-- $Id$ CDDL HEADER START The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. See LICENSE.txt included in this distribution for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at LICENSE.txt. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] CDDL HEADER END Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. Portions Copyright 2011 Jens Elkner. --%><%@page errorPage="error.jsp" import=" java.io.ByteArrayInputStream, java.io.OutputStream, java.io.BufferedReader, java.io.FileNotFoundException, java.io.InputStream, java.io.InputStreamReader, java.io.UnsupportedEncodingException, java.net.URLDecoder, java.util.ArrayList, org.suigeneris.jrcs.diff.Chunk, org.suigeneris.jrcs.diff.Delta, org.suigeneris.jrcs.diff.Diff, org.suigeneris.jrcs.diff.Revision, org.opengrok.indexer.analysis.AnalyzerGuru, org.opengrok.indexer.analysis.FileAnalyzer.Genre, org.opengrok.indexer.web.DiffData, org.opengrok.indexer.web.DiffType" %><%! private String getAnnotateRevision(DiffData data) { if (data.type == DiffType.OLD || data.type == DiffType.NEW) { String rev = data.rev[data.type == DiffType.NEW ? 1 : 0]; return ""; } return ""; } %> <% { PageConfig cfg = PageConfig.get(request); cfg.addScript("diff"); cfg.checkSourceRootExistence(); /** * This block must be the first block before any other output in the * response. * * If there is already any output written into the response and we * use the same response and reset the content and the headers then we have * a collision with the response streams and the "getOutputStream() has * already been called" exception occurs. */ DiffData data = cfg.getDiffData(); request.setAttribute("diff.jsp-data", data); if (data.type == DiffType.TEXT && request.getParameter("action") != null && request.getParameter("action").equals("download")) { try (OutputStream o = response.getOutputStream()) { for (int i = 0; i < data.revision.size(); i++) { Delta d = data.revision.getDelta(i); try (InputStream in = new ByteArrayInputStream(d.toString().getBytes("UTF-8"))) { response.setHeader("content-disposition", "attachment; filename=" + cfg.getResourceFile().getName() + "@" + data.rev[0] + "-" + data.rev[1] + ".diff"); byte[] buffer = new byte[8192]; int nr; while ((nr = in.read(buffer)) > 0) { o.write(buffer, 0, nr); } } } o.flush(); o.close(); return; } } } %><%@ include file="mast.jsp" %><% /* ---------------------- diff.jsp start --------------------- */ { PageConfig cfg = PageConfig.get(request); DiffData data = (DiffData) request.getAttribute("diff.jsp-data"); // the data is never null as the getDiffData always return valid object if (data.errorMsg != null) { %>
<%= data.errorMsg %>
<%= data.filename %> (revision <%= data.rev[0] %>) | <%= data.filename %> (revision <%= data.rev[1] %>) |
---|---|
<%= data.filename %> (<%= data.rev[0] %>) | <%= data.filename %> (<%= data.rev[1] %>) | |
---|---|---|
<%
if (full || (cn2 - ln2 < 20)) {
for (int j = ln2; j < cn2; j++) {
%><%= ++ln2 %><%=
Util.htmlize(file2[j]) %> <% } } else { for (int j = ln2; j < ln2 + 8; j++) { %><%= j+1 %><%= Util.htmlize(file2[j]) %> <% } %> --- <%= cn2 - ln2 - 16 %> unchanged lines hidden (view full) --- <% ln2 = cn2 - 8; for (int j = ln2; j < cn2; j++) { %><%= ++ln2 %><%= Util.htmlize(file2[j]) %> <% } } %> |
||
<%
for (int j = cn1; j <= cl1 ; j++) {
%> <% } %> |
||
<%
for (int j = cn2; j < cl2; j++) {
%><%= ++ln2 %><%= file2[j]
%> <% } %><%= ++ln2 %><%= file2[cl2] %><% if(full) { %><% } %> |
||
<%
if (full || cn2 - ln2 < 20) {
for (int j = ln1; j < cn1; j++) {
%><%= ++ln1 %><%=
Util.htmlize(file1[j]) %> <% } %> | <%
for (int j = ln2; j < cn2 ; j++) {
%><%= ++ln2 %><%=
Util.htmlize(file2[j]) %> <% } } else { for (int j = ln1; j < ln1 + 8; j++) { %><%= j+1 %><%= Util.htmlize(file1[j]) %> <% } %> --- <%= cn1 - ln1 - 16 %> unchanged lines hidden (view full) --- <% ln1 = cn1 - 8; for (int j = ln1; j < cn1; j++) { %><%= ++ln1 %><%= Util.htmlize(file1[j]) %> <% } %> | <%
for (int j = ln2; j < ln2 + 8; j++) {
%><%= j+1 %><%=
Util.htmlize(file2[j]) %> <% } %> --- <%= cn2 - ln2 - 16 %> unchanged lines hidden (view full) --- <% ln2 = cn2 - 8; for (int j = ln2; j < cn2; j++) { %><%= ++ln2 %><%= Util.htmlize(file2[j]) %> <% } } %> |
<%
for (int j = cn1; j <= cl1; j++) {
%><%= ++ln1 %><%= file1[j] %> <% } %> | <%
for (int j = cn2; j <= cl2; j++) {
%><%= ++ln2 %><%=
file2[j] %> <% } %> |
|
<%
for (int j = ln1; j < file1.length ; j++) {
%><%= j+1 %><%= Util.htmlize(file1[j]) %> <% } %> | <%
for (int j = ln2; j < file2.length ; j++) {
%><%= j+1 %><%= Util.htmlize(file2[j]) %> <% } %> |