history.jsp revision 1481
<%--
$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) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
Portions Copyright 2011, 2012 Jens Elkner.
--%><%@page import="
java.io.File,
java.text.Format,
java.text.SimpleDateFormat,
java.util.Date,
java.util.EnumSet,
java.util.Set,
java.util.regex.Pattern,
org.opensolaris.opengrok.Info,
org.opensolaris.opengrok.configuration.Configuration,
org.opensolaris.opengrok.configuration.Project,
org.opensolaris.opengrok.history.History,
org.opensolaris.opengrok.history.HistoryEntry,
org.opensolaris.opengrok.history.HistoryGuru,
org.opensolaris.opengrok.web.PageConfig,
org.opensolaris.opengrok.web.Prefix,
org.opensolaris.opengrok.web.Util,
org.opensolaris.opengrok.web.WebappListener"
%><%@
include file="mast.jspf"
%><%/* ---------------------- history.jsp start --------------------- */
{
PageConfig cfg = PageConfig.get(request);
String path = cfg.getPath();
if (path.length() > 0) {
String context = request.getContextPath();
Configuration conf = cfg.getConfig();
String uriEncodedName = cfg.getUriEncodedPath();
boolean striked = false;
String userPage = conf.getUserPage();
String userPageSuffix = conf.getUserPageSuffix();
if (userPageSuffix == null) {
// Set to empty string so we can append it to the URL
// unconditionally later.
userPageSuffix = "";
}
String bugPage = conf.getBugPage();
String bugRegex = conf.getBugPattern();
if (bugRegex == null || bugRegex.equals("")) {
bugRegex = "\\b([12456789][0-9]{6})\\b";
}
Pattern bugPattern = Pattern.compile(bugRegex);
String reviewPage = conf.getReviewPage();
String reviewRegex = conf.getReviewPattern();
if(reviewRegex == null || reviewRegex.equals("")) {
reviewRegex = "\\b(\\d{4}/\\d{3})\\b";
}
Pattern reviewPattern = Pattern.compile(reviewRegex);
Format df = new SimpleDateFormat("dd-MMM-yyyy");
History hist = null;
try {
hist = HistoryGuru.getInstance()
.getHistory(new File(cfg.getSourceRootPath(), path),
true, cfg.isDir());
} catch (Exception e) {
// should not happen
%><h3>Problem</h3><p class="error"><%= e.getMessage() %></p><%
}
if (hist != null) {
%><script type="text/javascript">/* <![CDATA[ */
O.hasFileList=<%= hist.hasFileList() %>;
O.domReady.push(O.domReadyHistory);
/* ]]> */</script>
<form action="<%= context + Prefix.DIFF_P + uriEncodedName %>">
<table class="src" id="revisions">
<caption>History log of <a href="<%= context + Prefix.XREF_P
+ uriEncodedName %>"><%= Util.htmlize(path) %></a></caption>
<thead>
<tr>
<th>Revision</th><%
if (!cfg.isDir()) {
%>
<th><button type="submit">Compare</button></th><%
}
%>
<th>Date</th>
<th>Author</th>
<th>Comments <a><span id="expand"></span> Expand </a></th>
</tr>
</thead>
<tbody>
<%
int count=0;
String subdir = path;
if (!subdir.endsWith("/")) {
int idx = subdir.lastIndexOf('/');
assert(idx != 0);
subdir = subdir.substring(0, idx+1);
}
String htmlPath = Util.formQuoteEscape(path);
for (HistoryEntry entry : hist.getHistoryEntries()) {
String rev = entry.getRevision();
String encodedRev;
String fullRev = entry.getOldRevision();
if (rev == null || rev.length() == 0) {
rev = "";
encodedRev = "";
} else {
encodedRev = "?r=" + Util.uriEncodeQueryValue(rev);
}
if (fullRev != null) {
fullRev = rev + " " + fullRev;
} else {
fullRev = rev;
}
%>
<tr><%
if (cfg.isDir()) {
%>
<td><%= fullRev %></td><%
} else if (entry.isActive()) {
%>
<td><a name="<%= rev %>" href="<%=
context + Prefix.XREF_P + uriEncodedName + encodedRev %>"><%= fullRev %></a></td>
<td>
<input type="radio"<%
if (count == 0 ) {
%> disabled="disabled"<%
} else if (count == 1) {
%> checked="checked"<%
}
%> name="r1" value="<%= htmlPath %>@<%= rev %>"/>
<input type="radio"
name="r2"<%
if (count == 0) {
%> checked="checked"<%
}
%> value="<%= htmlPath %>@<%= rev %>"/></td><%
} else {
striked = true;
%>
<td><del><%= rev %></del></td>
<td></td><%
}
%>
<td><%
Date date = entry.getDate();
if (date != null) {
%><%= df.format(date) %><%
}
%></td>
<td><%
String author = entry.getAuthor();
if (author == null) {
%>(no author)<%
} else if (userPage != null && userPage.length() > 0) {
String alink = Util.getEmail(author);
%><a href="<%= userPage + Util.uriEncodePath(alink) + userPageSuffix
%>"><%= Util.htmlize(author)%></a><%
} else {
%><%= Util.htmlize(author) %><%
}
%></td>
<td><p><%
String cout = Util.htmlize(entry.getMessage());
if (bugPage != null && bugPage.length() > 0) {
cout = bugPattern.matcher(cout).replaceAll("<a href=\""
+ bugPage + "$1\">$1</a>");
}
if (reviewPage != null && reviewPage.length() > 0) {
cout = reviewPattern.matcher(cout).replaceAll("<a href=\""
+ reviewPage + "$1\">$1</a>");
}
%><%= cout %></p><%
Set<String> files = entry.getFiles();
if (files != null) {
%><div style='display: none'><%
for (String ifile : files) {
String jfile = ifile;
if (ifile.startsWith(subdir)
&& ifile.length() > subdir.length())
{
jfile = ifile.substring(subdir.length());
}
%>
<a class="revh" href="<%= context + Prefix.XREF_P + Util.uriEncodePath(ifile)
+ encodedRev %>"><%= Util.htmlize(jfile) %></a><%
}
%></div><%
}
%></td>
</tr><%
count++;
}
%>
</tbody>
</table>
</form><%
if (striked) {
%><p><b>Note:</b> No associated file changes are available for
revisions with strike-through numbers (eg. <del>1.45</del>)</p><%
}
%>
<p class="rssbadge"><a href="<%=context + Prefix.RSS_P + uriEncodedName
%>" title="RSS XML Feed of latest changes"><span id="rssi"></span></a></p><%
}
}
}
/* ---------------------- history.jsp end --------------------- */
%><%@
include file="foot.jspf"
%>