diff.jsp revision 17b343cecb69da82215b124f39fed80167a6f2bd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteThe contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCommon Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteYou may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSee LICENSE.txt included in this distribution for the specific
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelanguage governing permissions and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWhen distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefile and include the License file at LICENSE.txt.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIf applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteinformation: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCopyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteUse is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteident "@(#)diff.jsp 1.2 05/12/01 SMI"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte--%><%@ page import = "javax.servlet.*,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte%><%@include file="mast.jsp"%><%!
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteString readableLine(int n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (n < 10) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return " " + n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte final String rp1 = request.getParameter("r1");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte final String rp2 = request.getParameter("r2");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte String srcRoot = environment.getSourceRootFile().getAbsolutePath();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte String r1 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte String r2 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte File rpath1 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte File rpath2 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte String[] tmp=null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rp1!=null) tmp = rp1.split("@");
d4b0f84707225327c617c6838361d3cfb7762b34Jack Meng if (tmp != null && tmp.length == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rpath1 = new File(srcRoot+URLDecoder.decode(tmp[0], "UTF-8"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte r1 = URLDecoder.decode(tmp[1], "UTF-8");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (UnsupportedEncodingException e) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rp2!=null) tmp = rp2.split("@");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp != null && tmp.length == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp != null && tmp.length == 2) {
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe rpath2 = new File(srcRoot+URLDecoder.decode(tmp[0], "UTF-8"));
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe r2 = URLDecoder.decode(tmp[1], "UTF-8");
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe } catch (UnsupportedEncodingException e) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (r1 == null || r2 == null || r1.equals("") || r2.equals("") || r1.equals(r2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte%><div class="src"><h3 class="error">Error:</h3>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Please pick two revisions to compare the changed from the <a href="<%=context+Constants.histL+path%>">history</a>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte// Error message ask to choose two versions from History log page with link to it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Genre g = AnalyzerGuru.getGenre(basename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g == Genre.PLAIN || g == null || g == Genre.DATA || g == Genre.HTML) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InputStream in1 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InputStream in2 = null;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in1 = HistoryGuru.getInstance().getRevision(rpath1.getParent(), rpath1.getName(), r1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in2 = HistoryGuru.getInstance().getRevision(rpath2.getParent(), rpath2.getName(), r2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (Exception e) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte %> <h3 class="error">Error opening revisions!</h3> <%
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (in1 != null && in2 != null) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g == null) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte %> <div id="difftable">
<table rules="cols" cellpadding="5"><tr><th><%=basename%> (revision <%=r1%>)</th><th><%=basename%> (revision <%=r2%>)</th></tr>
<tr><td><img src="<%=context+Constants.rawP+path%>?r=<%=r1%>"/></td><td><img src="<%=context+Constants.rawP+path%>?r=<%=r2%>"/></td></tr></table></div><%
while ((line = reader1.readLine()) != null) {
l1.add(line);
while ((line = reader2.readLine()) != null) {
l2.add(line);
Object[] file1 = l1.toArray();
Object[] file2 = l2.toArray();
Revision rev = Diff.diff(file1, file2);
if(rev.size() == 0) {
String format = request.getParameter("format");
if(format == null || (!format.equals("o") && !format.equals("n") && !format.equals("u") && !format.equals("t")))
String pfull = request.getParameter("full");
boolean full = pfull != null && pfull.equals("1");
%><div id="difftable"><div id="diffbar"><span class="tabsel"> <span class="d"> Deleted </span> <span class="a"> Added </span> </span> | <%
if(format.equals("s")) {
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=s&full=<%=pfull%>">sdiff</a></span> <%
if(format.equals("u")) {
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=u&full=<%=pfull%>">udiff</a></span> <%
if(format.equals("t")) {
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=t&full=<%=pfull%>">text</a></span> <%
if(format.equals("o")) {
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=o&full=<%=pfull%>">old (<%=r1%>)</a></span> <%
if(format.equals("n")) {
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=n&full=<%=pfull%>">new (<%=r2%>)</a></span> | <%
%><span class="tab"><a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1"> full </a></span> <span class="tabsel"><b>compact</b></span><%
%><span class="tabsel"><b> full </b> </span> <span class="tab"> <a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=0">compact</a></span><%
if(format.equals("s")) {
for (int i=0; i < rev.size(); i++) {
Delta d = rev.getDelta(i);
if(format.equals("t")) {
Chunk c1 = d.getOriginal();
Chunk c2 = d.getRevised();
int cn1 = c1.first();
int cl1 = c1.last();
int cn2 = c2.first();
int cl2 = c2.last();
file1[h] = Util.htmlize((String)file1[h]);
file2[h] = Util.htmlize((String)file2[h]);
if (format.equals("u")) {
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=readableLine(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/>--- <b><%=cn2 - ln2 - 16%> unchanged lines hidden</b> (<a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1#<%=ln2%>">view full</a>) --- <br/><br/><%
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
} else if(format.equals("s")) {
%><i><%=readableLine(++ln1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=readableLine(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><br/>--- <b><%=cn1 - ln1 - 16%> unchanged lines hidden</b> (<a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1#<%=ln2%>">view full</a>) --- <br/><br/><%
%><i><%=readableLine(++ln1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><i><%=readableLine(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/>--- <b><%=cn2 - ln2 - 16%> unchanged lines hidden</b> (<a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1#<%=ln2%>">view full</a>) --- <br/><br/><%
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
} else if ( format.equals("o")) {
%><i><%=readableLine(++ln1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><i><%=readableLine(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><br/>--- <b><%=cn1 - ln1 - 16%> unchanged lines hidden</b> (<a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1#<%=ln1%>">view full</a>) --- <br/><br/><%
%><i><%=readableLine(++ln1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
} else if ( format.equals("n")) {
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=readableLine(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/>--- <b><%=cn2 - ln2 - 16%> unchanged lines hidden</b> (<a href="<%=reqURI%>?r1=<%=rp1%>&r2=<%=rp2%>&format=<%=format%>&full=1#<%=ln2%>">view full</a>) --- <br/><br/><%
%><i><%=readableLine(++ln2)%></i><%=Util.htmlize((String)file2[j])%><br/><%
if (file1.length >= ln1) {
if (format.equals("s")) {
if (full || file1.length - ln1 < 20) {
for (int j = ln1; j < file1.length ; j++) {
%><i><%=(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
for (int j = ln2; j < file2.length ; j++) {
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><br/> --- <b><%=file1.length - ln1 - 8%> unchanged lines hidden</b> --- </td><td><%
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/>--- <b><%=file1.length - ln1 - 8%> unchanged lines hidden</b> ---</td></tr></table><%
} else if (format.equals("u")) {
if (full || file2.length - ln2 < 20) {
for (int j = ln2; j < file2.length ; j++) {
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/>--- <b><%=file2.length - ln2 - 8%> unchanged lines hidden</b> ---</td></tr></table><%
} else if (format.equals("o")) {
if (full || file1.length - ln1 < 20) {
for (int j = ln1; j < file1.length ; j++) {
%><i><%=(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><i><%=(j+1)%></i><%=Util.htmlize((String)file1[j])%><br/><%
%><br/> --- <b><%=file1.length - ln1 - 8%> unchanged lines hidden</b> ---<br/><%
} else if (format.equals("n")) {
if (full || file2.length - ln2 < 20) {
for (int j = ln2; j < file2.length ; j++) {
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><i><%=(j+1)%></i><%=Util.htmlize((String)file2[j])%><br/><%
%><br/> --- <b><%=file2.length - ln2 - 8%> unchanged lines hidden</b> ---<br/><%
%> <div id="src">Diffs for binary files cannot be displayed! Files are <a href="<%=context+Constants.rawP+path%>?r=<%=r1%>"><%=basename%>(revision <%=r1%>)</a> and
<a href="<%=context+Constants.rawP+path%>?r=<%=r2%>"><%=basename%>(revision <%=r2%>)</a>.
%><div class="src"><h3 class="error">Error Opening files! <%=Util.htmlize(e.getMessage())%></h3></div><%
in1.close();
in2.close();
} else if (g == Genre.IMAGE) {
<table rules="cols" cellpadding="5"><tr><th><%=basename%> (revision <%=r1%>)</th><th><%=basename%> (revision <%=r2%>)</th></tr>
<tr><td><img src="<%=context+Constants.rawP+path%>?r=<%=r1%>"/></td><td><img src="<%=context+Constants.rawP+path%>?r=<%=r2%>"/></td></tr></table></div><%
%> <div class="src">Diffs for binary files cannot be displayed. Files are <a href="<%=context+Constants.rawP+path%>?r=<%=r1%>"><%=basename%>(revision <%=r1%>)</a> and
<a href="<%=context+Constants.rawP+path%>?r=<%=r2%>"><%=basename%>(revision <%=r2%>)</a>.
%><%@include file="foot.jspf"%><%