diff.jsp revision 1478
1281N/A<%--
1186N/A$Id$
1186N/A
0N/ACDDL HEADER START
0N/A
0N/AThe contents of this file are subject to the terms of the
1281N/ACommon Development and Distribution License (the "License").
0N/AYou may not use this file except in compliance with the License.
0N/A
0N/ASee LICENSE.txt included in this distribution for the specific
0N/Alanguage governing permissions and limitations under the License.
0N/A
0N/AWhen distributing Covered Code, include this CDDL HEADER in each
0N/Afile and include the License file at LICENSE.txt.
0N/AIf applicable, add the following below this CDDL HEADER, with the
0N/Afields enclosed by brackets "[]" replaced with your own identifying
0N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
0N/A
0N/ACDDL HEADER END
0N/A
830N/ACopyright 2009 Sun Microsystems, Inc. All rights reserved.
0N/AUse is subject to license terms.
0N/A
1186N/APortions Copyright 2011 Jens Elkner.
1186N/A--%><%@page import="
1478N/Ajava.util.EnumSet,
0N/A
1186N/Aorg.apache.commons.jrcs.diff.Chunk,
1186N/Aorg.apache.commons.jrcs.diff.Delta,
1478N/A
1478N/Aorg.opensolaris.opengrok.Info,
1478N/Aorg.opensolaris.opengrok.configuration.Project,
0N/Aorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
1186N/Aorg.opensolaris.opengrok.web.DiffData,
1478N/Aorg.opensolaris.opengrok.web.DiffType,
1478N/Aorg.opensolaris.opengrok.web.PageConfig,
1478N/Aorg.opensolaris.opengrok.web.Prefix,
1478N/Aorg.opensolaris.opengrok.web.Util,
1478N/Aorg.opensolaris.opengrok.web.WebappListener"
1186N/A%><%!
1388N/Aprivate static final String getAnnotateRevision(DiffData dd) {
1468N/A StringBuilder sb = new StringBuilder("<script type=\"text/javascript\">/* <![CDATA[ */ ");
1468N/A // let the client side know, which revision is shown if it is a single file
1388N/A if (dd.type == DiffType.OLD || dd.type == DiffType.NEW) {
1468N/A sb.append("O.rev='r=")
1468N/A .append(dd.type == DiffType.NEW ? dd.rev2 : dd.rev1).append("';");
1468N/A } else if (dd.type == DiffType.WDIFF) {
1468N/A sb.append("O.domReady.push(O.domReadyDiff);");
1468N/A } else {
1468N/A return "";
1388N/A }
1468N/A sb.append(" /* ]]> */</script>");
1468N/A return sb.toString();
1468N/A}
1468N/A
1468N/A/** Info container for hidden blocks */
1468N/Aprivate class Hidden {
1468N/A /** line# of the first line of the leading block */
1468N/A int start;
1468N/A /** number of lines in the leading block */
1468N/A int leading;
1468N/A /** number of lines in the hidden block */
1468N/A int hidden;
1468N/A /** number of lines in the trailing block */
1468N/A int trailing;
1468N/A /** buffer which contains the formatted line numbers after hidden lines */
1468N/A StringBuilder bn;
1468N/A /** buffer which contains the formatted source lines after hidden lines */
1468N/A StringBuilder bs;
1468N/A /** if {@code true} dump all, i.e. no hidden lines */
1468N/A boolean full;
1468N/A /**
1468N/A * Create a new instance with initialized StringBuilders
1468N/A * @param full if {@code true} dump all, i.e. no hidden lines *
1468N/A */
1468N/A public Hidden(boolean full) {
1468N/A bn = new StringBuilder(32);
1468N/A bs = new StringBuilder(256);
1468N/A this.full = full;
1468N/A }
1468N/A
1468N/A /**
1468N/A * Reset and prepare buffers to take new content.
1468N/A * @param start line# of the first line of the leading block
1468N/A * @param leading Number of leading lines
1468N/A * @param hidden Number of lines in the hidden block
1468N/A * @param trailing Number of trailing lines
1468N/A */
1468N/A public void reset(int start, int leading, int hidden, int trailing) {
1468N/A this.start = start;
1468N/A this.leading = leading;
1468N/A this.hidden = hidden;
1468N/A this.trailing = trailing;
1468N/A bn.setLength(0);
1468N/A bs.setLength(0);
1468N/A }
1468N/A /** {@inheritDoc} */
1468N/A @Override
1468N/A public String toString() {
1468N/A return "{ start=" + start + "; leading=" + leading + "; hidden=" + hidden
1468N/A + "; trailing=" + trailing + "; full=" + full
1468N/A + " }";
1468N/A }
1388N/A}
1388N/A
1388N/A/**
1468N/A * Dump unchanged lines of a file. lines get htmlized.
1468N/A * @param line Current line# (start of dump)
1468N/A * @param howMany Number of lines to dump.
1468N/A * @param trailing Number of trailing lines to print after a "hidden" block
1468N/A * (leading is always 8).
1468N/A * @param file Source code lines of the file to partially dump.
1468N/A * @param bn Where to append formatted line numbers
1468N/A * @param bs Where to append dumped formatted source code lines
1468N/A * @param h Where to store info about leading, hidden, trailing blocks
1468N/A * @param a If {code true}, line numbers get an anchor named with the line#
1468N/A * (can't use IDs instead of name, because IDs need to be unique)
1468N/A * @return line# + 1 of the last line dumped
1388N/A * @throws IndexOutOfBoundsException if <var>file</var> contains less than
1468N/A * <var>line</var> + <var>howMany</var> entries.
1388N/A */
1388N/Aprivate static final int dumpFile(int line, int howMany, int trailing,
1468N/A String[] file, StringBuilder bn, StringBuilder bs, Hidden h, boolean a)
1388N/A{
1388N/A int max = line + howMany;
1468N/A // if we have fewer lines than leading+trailing+min_hidden lines, dump all
1468N/A if (h.full || howMany < 20) {
1468N/A h.reset(line, howMany, 0, 0);
1468N/A for (;line < max; line++) {
1388N/A if (a) {
1388N/A bn.append("<a name=\"").append(line).append("\">")
1388N/A .append(line).append("</a>\n");
1388N/A } else {
1388N/A bn.append(line).append('\n');
1388N/A }
1388N/A bs.append(Util.htmlize(file[line-1])).append('\n');
1388N/A }
1388N/A } else {
1468N/A // leading block (row n)
1468N/A for (int j = line; j < line + 8; j++) {
1388N/A if (a) {
1388N/A bn.append("<a name=\"").append(j).append("\">")
1388N/A .append(j).append("</a>\n");
1388N/A } else {
1388N/A bn.append(j).append('\n');
1388N/A }
1388N/A bs.append(Util.htmlize(file[j-1])).append('\n');
1388N/A }
1468N/A h.reset(line, 8, howMany - 8 - trailing, trailing); // hidden block (row n+1)
1468N/A bs = h.bs;
1468N/A bn = h.bn;
1468N/A // trailing block (row n+2)
1468N/A line += howMany - trailing ;
1468N/A for (; line < max; line++) {
1388N/A if (a) {
1388N/A bn.append("<a name=\"").append(line).append("\">")
1388N/A .append(line).append("</a>\n");
1388N/A } else {
1388N/A bn.append(line).append('\n');
1388N/A }
1388N/A bs.append(Util.htmlize(file[line-1])).append('\n');
1388N/A }
1388N/A }
1468N/A return line;
1388N/A}
1388N/A
1468N/A/**
1468N/A * Dump a chunk of deleted or added source lines. lines get not htmlized.
1468N/A * @param cn line# of the first line in the file to format (start of dump)
1468N/A * @param cl line# of the last line in the file to format (end of dump)
1468N/A * @param line line# of the new file, which corresponds to <var>cn</var>
1468N/A * @param file file from which the chunk should be dumped
1468N/A * @param bn where to store formatted line numbers
1468N/A * @param bs where to store formatted source code
1468N/A * @param a if {code true}, line numbers get an anchor named with the line#
1468N/A * (can't use IDs instead of name, because IDs need to be unique)
1468N/A * @return line# + 1 of the last line dumped
1468N/A */
1468N/Aprivate static final int dumpChunk(int cn, int cl, int line, String[] file,
1388N/A StringBuilder bn, StringBuilder bs, boolean a)
1388N/A{
1468N/A for (int j = cn - 1; j < cl ; j++, line++) {
1388N/A if (a) {
1388N/A bn.append("<a name=\"").append(line).append("\">")
1388N/A .append(line).append("</a>\n");
1388N/A } else {
1388N/A bn.append(line).append('\n');
1388N/A }
1388N/A bs.append(file[j]).append('\n');
1388N/A }
1468N/A return line;
1468N/A}
1468N/A
1468N/A private static final String getHiddenBlockInfo(Hidden h, DiffData dd) {
1468N/A return "<b>" + h.hidden + " unchanged lines hidden</b>"
1468N/A + (dd.type == DiffType.WDIFF ? "" : " (<a href=\""
1468N/A + dd.reqURI + "?r1=" + dd.rp1 + "&amp;r2=" + dd.rp2 + "&amp;format="
1468N/A + dd.type.getAbbrev() + "&amp;full=1#" + (h.start + h.leading)
1468N/A + "\">view full</a>) ");
1468N/A }
1468N/A
1468N/A/**
1468N/A * Dump a sequence of numbers.
1468N/A * @param n first number to dump
1468N/A * @param count # of numbers to dump
1468N/A * @param bn buffer to use. Gets reset before appending stuff.
1468N/A * @return last number dumped + 1
1468N/A */
1468N/Aprivate static final int genNums(int n, int count, StringBuilder bn) {
1468N/A bn.setLength(0);
1468N/A int last = n + count;
1468N/A for (; n < last ; n++) {
1468N/A bn.append(n).append('\n');
1468N/A }
1468N/A return n;
1186N/A}
1465N/A
1465N/Aprivate static final String basename(String path) {
1468N/A int idx = path.lastIndexOf('/');
1468N/A if (idx < 0) {
1468N/A return path;
1468N/A }
1468N/A return path.substring(idx+1);
1465N/A}
1186N/A%><%@
0N/A
1478N/Ainclude file="mast.jspf"
0N/A
0N/A%><%
1186N/A/* ---------------------- diff.jsp start --------------------- */
1186N/A{
1388N/A cfg = PageConfig.get(request);
1388N/A DiffData dd = cfg.getDiffData();
1281N/A
1388N/A if (dd.errorMsg != null) {
0N/A
1186N/A%>
1186N/A<div class="src">
1468N/A <h3 class="error">Error:</h3>
1468N/A <p><%= dd.errorMsg %></p>
1186N/A</div><%
1186N/A
1388N/A } else if (dd.genre == Genre.IMAGE) {
1465N/A String link = request.getContextPath() + Prefix.RAW_P;
1465N/A int idx1 = dd.rp1.indexOf('@');
1465N/A int idx2 = dd.rp2.indexOf('@');
1186N/A%>
1186N/A<div id="difftable">
1468N/A <table class="dtimage">
1468N/A <thead>
1468N/A <tr><th title="<%= Util.htmlize(dd.fp1) %>"
1468N/A ><%= Util.htmlize(basename(dd.fp1)) %> (revision <%= dd.rev1 %>)</th>
1468N/A <th title="<%= Util.htmlize(dd.fp2) %>"
1468N/A ><%= Util.htmlize(basename(dd.fp2)) %> (revision <%= dd.rev2 %>)</th>
1468N/A </tr>
1468N/A </thead>
1468N/A <tbody>
1468N/A <tr><td class="dti"><img src="<%= link + dd.rp1.substring(0, idx1)
1468N/A %>?r=<%= dd.rp1.substring(idx1 + 2) %>"/></td>
1468N/A <td class="dti"><img src="<%= link + dd.rp2.substring(0, idx2)
1468N/A %>?r=<%= dd.rp2.substring(idx2 + 2) %>"/></td>
1468N/A </tr>
1468N/A </tbody>
1468N/A </table>
1186N/A</div><%
170N/A
1388N/A } else if (dd.genre != Genre.PLAIN && dd.genre != Genre.HTML) {
1465N/A String link = request.getContextPath() + Prefix.RAW_P;
1465N/A int idx1 = dd.rp1.indexOf('@');
1465N/A int idx2 = dd.rp2.indexOf('@');
1186N/A%>
1281N/A<div id="src">Diffs for binary files cannot be displayed! Files are <a
1465N/A href="<%= link + dd.rp1.substring(0, idx1) %>?r=<%= dd.rp1.substring(idx1 + 2)
1465N/A %>" title="<%= Util.htmlize(dd.fp1) %>"
1465N/A ><%= Util.htmlize(basename(dd.fp1)) %>(revision <%= dd.rev1 %>)</a> and <a
1465N/A href="<%= link + dd.rp2.substring(0, idx2) %>?r=<%= dd.rp2.substring(idx2 + 2)
1465N/A %>" title="<%= Util.htmlize(dd.fp2) %>"
1465N/A ><%= Util.htmlize(basename(dd.fp2)) %>(revision <%= dd.rev2 %>)</a>.
0N/A</div><%
1388N/A } else if (dd.revision.size() == 0) {
1388N/A %>
1388N/A <%= getAnnotateRevision(dd) %>
1388N/A <b>No differences found!</b><%
1388N/A } else {
1388N/A //-------- Do THE DIFFS ------------
1186N/A%>
1388N/A<%= getAnnotateRevision(dd) %>
1186N/A<div id="diffbar">
1388N/A <div class="dblegend">
1388N/A <span class="m">Deleted</span>
1388N/A <span class="p">Added</span>
1388N/A </div>
1388N/A <div class="dbtabs"><%
1388N/A for (DiffType t : DiffType.values()) {
1388N/A if (dd.type == t) {
1388N/A %> <span class="active dbtab"><%= t.toString() %><%
1388N/A if (t == DiffType.OLD) {
1388N/A %> ( <%= dd.rev1 %> )<%
1388N/A } else if (t == DiffType.NEW) {
1388N/A %> ( <%= dd.rev2 %> )<%
1388N/A }
1388N/A %></span><%
1388N/A } else {
1388N/A %> <span class="dbtab"><a href="<%= dd.reqURI %>?r1=<%= dd.rp1
1388N/A %>&amp;r2=<%= dd.rp2 %>&amp;format=<%= t.getAbbrev()
1388N/A %>&amp;full=<%= dd.full ? '1' : '0' %>"><%= t.toString() %><%
1388N/A if (t == DiffType.OLD) {
1388N/A %> ( <%= dd.rev1 %> )<%
1388N/A } else if (t == DiffType.NEW) {
1388N/A %> ( <%= dd.rev2 %> )<%
1388N/A }
1388N/A %></a></span><%
1388N/A }
1388N/A }
1388N/A %></div>
1388N/A <div class="dbformats"><%
1388N/A if (!dd.full) {
1388N/A %>
1388N/A <span class="dbformat"><a href="<%= dd.reqURI %>?r1=<%= dd.rp1
1388N/A %>&amp;r2=<%= dd.rp2 %>&amp;format=<%= dd.type.getAbbrev()
1388N/A %>&amp;full=1">full</a></span>
1388N/A <span class="active dbformat">compact</span><%
1388N/A } else {
1388N/A %>
1388N/A <span class="active dbformat">full</span>
1388N/A <span class="dbformat"> <a href="<%= dd.reqURI %>?r1=<%= dd.rp1
1388N/A %>&amp;r2=<%= dd.rp2 %>&amp;format=<%= dd.type.getAbbrev()
1388N/A %>&amp;full=0">compact</a></span><%
1388N/A }
1388N/A %></div>
1186N/A</div>
1168N/A
1388N/A<div id="difftable"><%
1388N/A if (dd.type != DiffType.TEXT) {
1388N/A %><table id="<%= "dt" + dd.type %>"><%
1388N/A if (dd.type == DiffType.SIDEBYSIDE) {
1388N/A%>
1388N/A<thead><tr>
1465N/A <th colspan="2" title="<%= Util.htmlize(dd.fp1) %>"
1465N/A ><%= Util.htmlize(basename(dd.fp1)) %> (<%= dd.rev1 %>)</th>
1465N/A <th colspan="2" title="<%= Util.htmlize(dd.fp2) %>"
1465N/A ><%= Util.htmlize(basename(dd.fp2)) %> (<%= dd.rev2 %>)</th>
1388N/A</tr></thead><%
1468N/A } else if (dd.type == DiffType.WDIFF) {
1468N/A%>
1468N/A<thead class="dtk">
1468N/A <tr><th class="dtm" colspan="3" title="<%= Util.htmlize(dd.fp1) %>"
1468N/A ><%= Util.htmlize(dd.fp1) %> (<%= dd.rev1 %>)</th></tr>
1468N/A <tr><th class="dtp" colspan="3" title="<%= Util.htmlize(dd.fp2) %>"
1468N/A ><%= Util.htmlize(dd.fp2) %> (<%= dd.rev2 %>)</th></tr>
1468N/A</thead><%
1388N/A }
1388N/A%>
1388N/A <tbody><%
1388N/A }
1281N/A
1468N/A StringBuilder bs1 = new StringBuilder(256); // formatted source lines file1
1468N/A StringBuilder bs2 = new StringBuilder(256); // formatted source lines file2
1468N/A StringBuilder bn1 = new StringBuilder(32); // formatted line#s file1
1468N/A StringBuilder bn2 = new StringBuilder(32); // formatted line#s file2
1468N/A int ln1 = 1; // next line of file1 to process
1468N/A int ln2 = 1; // next line of file2 to process
1468N/A String[] file1 = dd.file[0]; // source lines of the 'old' file
1468N/A String[] file2 = dd.file[1]; // source lines of the 'new' file
1388N/A
1468N/A Hidden h1 = new Hidden(dd.full); // hidden line info + trailing stuff file1
1468N/A Hidden h2 = new Hidden(dd.full); // hidden line info + trailing stuff file2
1468N/A StringBuilder lna = null;
1468N/A if (dd.type == DiffType.WDIFF) {
1468N/A lna = new StringBuilder(32); // buffer for line#s
1468N/A }
1468N/A boolean like_udiff = dd.type == DiffType.UNIFIED || dd.type == DiffType.WDIFF;
1388N/A for (int i=0; i < dd.revision.size(); i++) {
1388N/A Delta d = dd.revision.getDelta(i);
1388N/A if (dd.type == DiffType.TEXT) {
1469N/A out.write(Util.htmlize(d.toString()));
1388N/A continue;
1388N/A }
1388N/A Chunk c1 = d.getOriginal();
1388N/A Chunk c2 = d.getRevised();
1468N/A int cn1 = c1.first() + 1; // line# of the 1st line of chunk file1
1468N/A int cl1 = c1.last() + 1; // line# of the last line of chunk file1
1468N/A int cn2 = c2.first() + 1; // line# of the 1st line of chunk file2
1468N/A int cl2 = c2.last() + 1; // line# of the last line of chunk file2
1168N/A
1468N/A int i1 = cn1 - 1, i2 = cn2 - 1; // current line# in file1, file2
1468N/A // changed
1468N/A for (; i1 < cl1 && i2 < cl2; i1++, i2++) {
1469N/A String[] ss = Util
1469N/A .diffline(Util.htmlize(file1[i1]), Util.htmlize(file2[i2]));
1388N/A file1[i1] = ss[0];
1388N/A file2[i2] = ss[1];
1388N/A }
1388N/A // deleted
1468N/A for (; i1 < cl1; i1++) {
1388N/A bs1.setLength(0);
1469N/A file1[i1] = bs1.append(Util.SPAN_D)
1469N/A .append(Util.htmlize(file1[i1])).append("</span>")
1469N/A .toString();
1388N/A }
1388N/A // added
1468N/A for (; i2 < cl2; i2++) {
1388N/A bs2.setLength(0);
1469N/A file2[i2] = bs2.append(Util.SPAN_A)
1469N/A .append(Util.htmlize(file2[i2])).append("</span>")
1469N/A .toString();
1388N/A }
1388N/A bn2.setLength(0);
1388N/A bs2.setLength(0);
1468N/A // To Dump flag: if == 1 normal, if == 2 sdiff, if == 3 wdiff row
1388N/A int td = 1;
1388N/A String tClass = " class='dtk'";
1388N/A if (dd.type == DiffType.OLD && cn1 > ln1) {
1388N/A tClass = "";
1468N/A ln1 = dumpFile(ln1, cn1 - ln1, 8, file1, bn2, bs2, h2, true);
1388N/A } else if (dd.type == DiffType.NEW && cn2 > ln2) {
1388N/A tClass = "";
1468N/A ln2 = dumpFile(ln2, cn2 - ln2, 8, file2, bn2, bs2, h2, true);
1468N/A } else if (like_udiff && (cn1 > ln1 || cn2 > ln2)) {
1468N/A ln2 = dumpFile(ln2, cn2 - ln2, 8, file2, bn2, bs2, h2, true);
1468N/A if (dd.type == DiffType.WDIFF) {
1468N/A bn1.setLength(0); // hidden source
1468N/A bs1.setLength(0); // line#s of hidden source
1468N/A h1.full = true; // dump all
1468N/A dumpFile(h2.start + h2.leading, h2.hidden, 0, file2, bn1, bs1, h1, false);
1468N/A h1.full = dd.full; // restore
1468N/A // h1 is not needed, so we abuse it to store linenums
1468N/A ln1 = genNums(ln1, h2.leading, h1.bn);
1468N/A ln1 = genNums(ln1, h2.hidden, lna);
1468N/A ln1 = genNums(ln1, h2.trailing, h1.bs);
1468N/A td = 3;
1468N/A }
1388N/A ln1 = cn1;
1388N/A } else if (dd.type == DiffType.SIDEBYSIDE && (cn1 > ln1 || cn2 > ln2)) {
1388N/A bn1.setLength(0);
1388N/A bs1.setLength(0);
1468N/A h1.full |= cn2 - ln2 + 1 < 20; // force same dump strategy for both
1468N/A ln1 = dumpFile(ln1, cn1 - ln1, 8, file1, bn1, bs1, h1, false);
1468N/A h1.full = dd.full; // restore
1468N/A ln2 = dumpFile(ln2, cn2 - ln2, 8, file2, bn2, bs2, h2, true);
1468N/A td = 2;
1388N/A } else {
1388N/A td = 0;
1388N/A }
1468N/A
1388N/A if (td > 0) {
1468N/A // leading block
1388N/A%>
1388N/A<tr <%= tClass %>><%
1468N/A if (td == 2) {
1388N/A %>
1388N/A <td class="dtn"><%= bn1 %></td>
1388N/A <td class="dts"><%= bs1 %></td><%
1468N/A } else if (td == 3) {
1468N/A %>
1468N/A <td class="dtn"><%= h1.bn %></td><%
1388N/A }
1388N/A %>
1388N/A <td class="dtn"><%= bn2 %></td>
1388N/A <td class="dts"><%= bs2 %></td>
1388N/A</tr><%
1468N/A // hidden block
1468N/A if (h2.hidden > 0) {
1468N/A%>
1468N/A<tr class="dtl" id="hi_<%= i %>"><%
1468N/A if (td < 3) {
1468N/A String txt = getHiddenBlockInfo(h2, dd);
1468N/A if (td == 2) {
1468N/A %>
1468N/A <td class="dth" colspan="2"><%= txt %></td><%
1468N/A }
1468N/A %>
1468N/A <td class="dth" colspan="2"><%= txt %></td><%
1468N/A } else {
1468N/A // wdiff
1468N/A %>
1468N/A <td class="dth" colspan="3"><%= getHiddenBlockInfo(h2, dd) %></td>
1468N/A</tr>
1468N/A<tr class="dte" id="hs_<%= i %>">
1468N/A <td class="dtn"><%= lna %></td>
1468N/A <td class="dtn"><%= bn1 %></td>
1468N/A <td class="dts"><%= bs1 %></td>
1468N/A <%
1468N/A }
1468N/A%>
1468N/A</tr><%
1468N/A }
1468N/A // trailing block
1468N/A if (h2.trailing > 0) {
1468N/A%>
1468N/A<tr <%= tClass %>><%
1468N/A if (td == 2) {
1468N/A %>
1468N/A <td class="dtn"><%= h1.bn %></td>
1468N/A <td class="dts"><%= h1.bs %></td><%
1468N/A } else if (td == 3) {
1468N/A %>
1468N/A <td class="dtn"><%= h1.bs %></td><%
1468N/A }
1468N/A %>
1468N/A <td class="dtn"><%= h2.bn %></td>
1468N/A <td class="dts"><%= h2.bs %></td>
1468N/A</tr><%
1468N/A }
1388N/A }
1468N/A
1468N/A // chunks
1388N/A bn2.setLength(0);
1388N/A bs2.setLength(0);
1388N/A td = 1;
1388N/A tClass = " class='dtk'";
1388N/A String tdClass = "dtp";
1388N/A if (dd.type == DiffType.OLD && cn1 <= cl1) {
1388N/A tdClass = "dtm"; tClass = "";
1388N/A ln1 = dumpChunk(cn1, cl1, ln1, file1, bn2, bs2, true);
1388N/A } else if (dd.type == DiffType.NEW && cn2 <= cl2) {
1388N/A tClass = "";
1388N/A ln2 = dumpChunk(cn2, cl2, ln2, file2, bn2, bs2, true);
1468N/A } else if (like_udiff) {
1388N/A td = 0;
1388N/A if (cn1 <= cl1) {
1388N/A ln1 = dumpChunk(cn1, cl1, ln1, file1, bn2, bs2, false);
1388N/A%>
1388N/A<tr>
1468N/A <td class="dtm"><%= dd.type == DiffType.WDIFF ? bn2 + "</td><td> " : bn2 %></td>
1388N/A <td class="dts"><%= bs2 %></td>
1388N/A</tr><%
1388N/A }
1388N/A if (cn2 <= cl2) {
1388N/A bn2.setLength(0);
1388N/A bs2.setLength(0);
1388N/A ln2 = dumpChunk(cn2, cl2, ln2, file2, bn2, bs2, true);
1388N/A td = 1;
1388N/A }
1388N/A } else if (dd.type == DiffType.SIDEBYSIDE
1388N/A && (cn1 <= cl1 || cn2 <= cl2))
1388N/A {
1388N/A bn1.setLength(0);
1388N/A bs1.setLength(0);
1388N/A ln1 = dumpChunk(cn1, cl1, ln1, file1, bn1, bs1, false);
1388N/A ln2 = dumpChunk(cn2, cl2, ln2, file2, bn2, bs2, true);
1468N/A td = 2;
1388N/A } else {
1388N/A td = 0;
1388N/A }
1388N/A if (td > 0) {
1388N/A%>
1388N/A<tr <%= tClass %>><%
1468N/A if (td == 2) {
1388N/A %>
1388N/A <td class="dtm"><%= bn1 %></td>
1388N/A <td class="dts"><%= bs1 %></td><%
1388N/A }
1468N/A if (dd.type == DiffType.WDIFF) { // important to not use <td/> !
1468N/A %><td> </td><%
1468N/A }
1388N/A %>
1388N/A <td class="<%= tdClass %>"><%= bn2 %></td>
1388N/A <td class="dts"><%= bs2 %></td>
1388N/A</tr><%
1388N/A }
1468N/A } // for revision.size(
1468N/A
1468N/A // deltas done, dump the remaining - the same as in the first part
1468N/A // of the loop, but without a trailing block
1388N/A if (file1.length >= ln1) {
1388N/A bn2.setLength(0);
1388N/A bs2.setLength(0);
1388N/A int td = 1;
1468N/A if (dd.type == DiffType.OLD && file1.length >= ln1) {
1468N/A ln1 = dumpFile(ln1, file1.length - ln1 + 1, 0, file1, bn2, bs2, h2, true);
1468N/A } else if (dd.type == DiffType.NEW && file2.length >= ln2) {
1468N/A ln2 = dumpFile(ln2, file2.length - ln2 + 1, 0, file2, bn2, bs2, h2, true);
1468N/A } else if (like_udiff && file2.length >= ln2) {
1468N/A ln2 = dumpFile(ln2, file2.length - ln2 + 1, 0, file2, bn2, bs2, h2, true);
1468N/A if (dd.type == DiffType.WDIFF) {
1468N/A bn1.setLength(0); // hidden source
1468N/A bs1.setLength(0); // line#s of hidden source
1468N/A h1.full = true; // dump all
1468N/A dumpFile(h2.start + h2.leading, h2.hidden, 0, file2, bn1, bs1, h1, false);
1468N/A h1.full = dd.full; // restore
1468N/A // h1 is not needed, so we abuse it to store linenums
1468N/A ln1 = genNums(ln1, h2.leading, h1.bn);
1468N/A ln1 = genNums(ln1, h2.hidden, lna);
1468N/A td = 3;
1468N/A }
1388N/A } else if (dd.type == DiffType.SIDEBYSIDE
1468N/A && (file1.length >= ln1 || file2.length >= ln2))
1388N/A {
1388N/A bn1.setLength(0);
1388N/A bs1.setLength(0);
1468N/A h1.full |= file1.length - ln1 + 1 < 20; // force same dump strategy for both
1468N/A ln1 = dumpFile(ln1, file1.length - ln1 + 1, 0, file1, bn1, bs1, h1, false);
1468N/A h1.full = dd.full; // restore
1468N/A ln2 = dumpFile(ln2, file2.length - ln2 + 1, 0, file2, bn2, bs2, h2, true);
1468N/A td = 2;
1388N/A } else {
1388N/A td = 0;
1388N/A }
1388N/A if (td > 0) {
1468N/A // leading block
1388N/A%>
1388N/A<tr><%
1468N/A if (td == 2) {
1388N/A %>
1388N/A <td class="dtn"><%= bn1 %></td>
1388N/A <td class="dts"><%= bs1 %></td><%
1468N/A } else if (td == 3) {
1468N/A %>
1468N/A <td class="dtn"><%= h1.bn %></td><%
1388N/A }
1388N/A %>
1388N/A <td class="dtn"><%= bn2 %></td>
1388N/A <td class="dts"><%= bs2 %></td>
1388N/A</tr><%
1468N/A // hidden block
1468N/A if (h2.hidden > 0) {
1468N/A%>
1468N/A<tr class="dtl" id="hi_<%= dd.revision.size() %>"><%
1468N/A if (td < 3) {
1468N/A String txt = getHiddenBlockInfo(h2, dd);
1468N/A if (td == 2) {
1468N/A %>
1468N/A <td class="dth" colspan="2"><%= txt %></td><%
1468N/A }
1468N/A %>
1468N/A <td class="dth" colspan="2"><%= txt %></td><%
1468N/A } else {
1468N/A // wdiff
1468N/A %>
1468N/A <td class="dth" colspan="3"><%= getHiddenBlockInfo(h2, dd) %></td>
1468N/A</tr>
1468N/A<tr class="dte" id="hs_<%= dd.revision.size() %>">
1468N/A <td class="dtn"><%= lna %></td>
1468N/A <td class="dtn"><%= bn1 %></td>
1468N/A <td class="dts"><%= bs1 %></td>
1468N/A <%
1468N/A }
1468N/A%>
1468N/A</tr><%
1468N/A }
1468N/A // trailing block is always empty, since last
1388N/A }
1388N/A } // EOFs
1388N/A if (dd.type != DiffType.TEXT ) {
1388N/A %>
1388N/A </tbody>
1388N/A </table><%
1388N/A }
0N/A
1186N/A//----DIFFS Done--------
1388N/A%></div><%
1388N/A }
1186N/A}
1186N/A/* ---------------------- diff.jsp end --------------------- */
1186N/A%><%@
0N/A
1186N/Ainclude file="foot.jspf"
0N/A
1186N/A%>