<classpathentry kind="src" path="src"/>\r
<classpathentry kind="src" path="contrib"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
- <classpathentry kind="lib" path="lib/jgit-0.11.3.jar" sourcepath="/org.eclipse.jgit"/>\r
- <classpathentry kind="lib" path="lib/jgit-http-0.11.3.jar" sourcepath="/org.eclipse.jgit.http.server"/>\r
<classpathentry kind="lib" path="ext/log4j-1.2.16.jar"/>\r
<classpathentry kind="lib" path="ext/servlet-api-2.5.jar"/>\r
<classpathentry kind="lib" path="ext/slf4j-api-1.6.1.jar"/>\r
<classpathentry kind="lib" path="ext/wicket-1.4.17.jar"/>\r
<classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.17.jar"/>\r
<classpathentry kind="lib" path="ext/wicket-extensions-1.4.17.jar"/>\r
+ <classpathentry kind="lib" path="lib/jgit-0.11.3.jar"/>\r
+ <classpathentry kind="lib" path="lib/jgit-http-0.11.3.jar"/>\r
<classpathentry kind="output" path="bin"/>\r
</classpath>\r
import org.eclipse.jgit.revwalk.RevTree;\r
import org.eclipse.jgit.revwalk.RevWalk;\r
import org.eclipse.jgit.treewalk.TreeWalk;\r
+import org.eclipse.jgit.treewalk.filter.AndTreeFilter;\r
import org.eclipse.jgit.treewalk.filter.PathFilter;\r
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;\r
import org.eclipse.jgit.treewalk.filter.TreeFilter;\r
}\r
\r
public static List<RevCommit> getRevLog(Repository r, String objectId, int offset, int maxCount) {\r
+ return getRevLog(r, objectId, null, offset, maxCount);\r
+ }\r
+ \r
+ public static List<RevCommit> getRevLog(Repository r, String objectId, String path, int offset, int maxCount) {\r
List<RevCommit> list = new ArrayList<RevCommit>();\r
try {\r
if (objectId == null || objectId.trim().length() == 0) {\r
RevWalk walk = new RevWalk(r);\r
ObjectId object = r.resolve(objectId);\r
walk.markStart(walk.parseCommit(object));\r
+ if (!StringUtils.isEmpty(path)) {\r
+ TreeFilter filter = AndTreeFilter.create(PathFilterGroup\r
+ .createFromStrings(Collections.singleton(path)),\r
+ TreeFilter.ANY_DIFF);\r
+ walk.setTreeFilter(filter);\r
+ }\r
Iterable<RevCommit> revlog = walk;\r
if (offset > 0) {\r
int count = 0;\r
import com.gitblit.wicket.pages.BranchesPage;\r
import com.gitblit.wicket.pages.CommitDiffPage;\r
import com.gitblit.wicket.pages.CommitPage;\r
+import com.gitblit.wicket.pages.HistoryPage;\r
import com.gitblit.wicket.pages.LogPage;\r
import com.gitblit.wicket.pages.PatchPage;\r
import com.gitblit.wicket.pages.RawPage;\r
mount(new MixedParamUrlCodingStrategy("/blobdiff", BlobDiffPage.class, new String[] { "r", "h", "f" }));\r
mount(new MixedParamUrlCodingStrategy("/commitdiff", CommitDiffPage.class, new String[] { "r", "h" }));\r
mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" }));\r
+ mount(new MixedParamUrlCodingStrategy("/history", HistoryPage.class, new String[] { "r", "h", "f" }));\r
\r
// setup ticgit urls\r
mount(new MixedParamUrlCodingStrategy("/ticgit", TicGitPage.class, new String[] { "r" }));\r
gb.logout = Logout\r
gb.username = Username\r
gb.password = Password\r
-gb.tagger = tagger
\ No newline at end of file
+gb.tagger = tagger\r
+gb.moreHistory = more history...\r
+gb.difftocurrent = diff to current
\ No newline at end of file
}\r
return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",page=" + pageNumber);\r
}\r
+ \r
+ public static PageParameters newHistoryPageParameter(String repositoryName, String objectId, String path, int pageNumber) {\r
+ if (pageNumber <= 1) {\r
+ return newObjectParameter(repositoryName, objectId);\r
+ }\r
+ return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path + ",page=" + pageNumber);\r
+ }\r
\r
public static String getRepositoryName(PageParameters params) {\r
return params.getString("r", "");\r
item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, newPathParameter(entry.path)));\r
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));\r
item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
- item.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+ item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, newPathParameter(entry.path)));\r
\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, newPathParameter(entry.path)));\r
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));\r
item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
- item.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+ item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, newPathParameter(entry.path)));\r
\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" \r
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" \r
+ xml:lang="en" \r
+ lang="en"> \r
+\r
+<body>\r
+<wicket:extend>\r
+\r
+ <!-- page nav links --> \r
+ <div wicket:id="pageLinks">[page links]</div>\r
+\r
+ <!-- pager links -->\r
+ <div style="padding-top:5px;padding-bottom:5px;">\r
+ <a wicket:id="firstPageTop"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageTop"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageTop"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+ </div>\r
+ \r
+ <!-- history -->\r
+ <div style="margin-top:5px;" wicket:id="historyPanel">[history panel]</div>\r
+\r
+ <!-- pager links -->\r
+ <div style="padding-bottom:5px;">\r
+ <a wicket:id="firstPageBottom"><wicket:message key="gb.pageFirst"></wicket:message></a> | <a wicket:id="prevPageBottom"><wicket:message key="gb.pagePrevious"></wicket:message></a> | <a wicket:id="nextPageBottom"><wicket:message key="gb.pageNext"></wicket:message></a> \r
+ </div>\r
+\r
+</wicket:extend>\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+package com.gitblit.wicket.pages;\r
+\r
+import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+\r
+import com.gitblit.wicket.RepositoryPage;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.panels.HistoryPanel;\r
+\r
+public class HistoryPage extends RepositoryPage {\r
+\r
+ public HistoryPage(PageParameters params) {\r
+ super(params);\r
+\r
+ String path = WicketUtils.getPath(params);\r
+ int pageNumber = WicketUtils.getPage(params);\r
+ int prevPage = Math.max(0, pageNumber - 1);\r
+ int nextPage = pageNumber + 1;\r
+\r
+ HistoryPanel history = new HistoryPanel("historyPanel", repositoryName, objectId, path, getRepository(), -1, pageNumber - 1);\r
+ boolean hasMore = history.hasMore();\r
+ add(history);\r
+\r
+ add(new BookmarkablePageLink<Void>("firstPageTop", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)).setEnabled(pageNumber > 1));\r
+ add(new BookmarkablePageLink<Void>("prevPageTop", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage)).setEnabled(pageNumber > 1));\r
+ add(new BookmarkablePageLink<Void>("nextPageTop", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage)).setEnabled(hasMore));\r
+\r
+ add(new BookmarkablePageLink<Void>("firstPageBottom", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)).setEnabled(pageNumber > 1));\r
+ add(new BookmarkablePageLink<Void>("prevPageBottom", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, prevPage)).setEnabled(pageNumber > 1));\r
+ add(new BookmarkablePageLink<Void>("nextPageBottom", HistoryPage.class, WicketUtils.newHistoryPageParameter(repositoryName, objectId, path, nextPage)).setEnabled(hasMore));\r
+\r
+ }\r
+\r
+ @Override\r
+ protected String getPageName() {\r
+ return getString("gb.history");\r
+ }\r
+}\r
int pageNumber = WicketUtils.getPage(params);\r
int prevPage = Math.max(0, pageNumber - 1);\r
int nextPage = pageNumber + 1;\r
+ LogPanel logPanel = new LogPanel("logPanel", repositoryName, objectId, getRepository(), -1, pageNumber - 1);\r
+ boolean hasMore = logPanel.hasMore();\r
+ add(logPanel);\r
\r
- add(new BookmarkablePageLink<Void>("firstPageTop", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));\r
+ add(new BookmarkablePageLink<Void>("firstPageTop", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)).setEnabled(pageNumber > 1));\r
add(new BookmarkablePageLink<Void>("prevPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1));\r
- add(new BookmarkablePageLink<Void>("nextPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)));\r
+ add(new BookmarkablePageLink<Void>("nextPageTop", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)).setEnabled(hasMore));\r
\r
- add(new LogPanel("logPanel", repositoryName, objectId, getRepository(), -1, pageNumber - 1));\r
-\r
- add(new BookmarkablePageLink<Void>("firstPageBottom", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));\r
+ add(new BookmarkablePageLink<Void>("firstPageBottom", LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)).setEnabled(pageNumber > 1));\r
add(new BookmarkablePageLink<Void>("prevPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, prevPage)).setEnabled(pageNumber > 1));\r
- add(new BookmarkablePageLink<Void>("nextPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)));\r
+ add(new BookmarkablePageLink<Void>("nextPageBottom", LogPage.class, WicketUtils.newLogPageParameter(repositoryName, objectId, nextPage)).setEnabled(hasMore));\r
}\r
\r
@Override\r
public TreePage(PageParameters params) {\r
super(params);\r
\r
- final String basePath = WicketUtils.getPath(params);\r
+ final String path = WicketUtils.getPath(params);\r
\r
Repository r = getRepository();\r
RevCommit commit = JGitUtils.getCommit(r, objectId);\r
- List<PathModel> paths = JGitUtils.getFilesInPath(r, basePath, commit);\r
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\r
\r
// tree page links\r
add(new Label("historyLink", getString("gb.history")));\r
- add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, basePath)));\r
+ add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));\r
\r
add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));\r
\r
// breadcrumbs\r
- add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, objectId));\r
- if (basePath != null && basePath.trim().length() > 0) {\r
- paths.add(0, PathModel.getParentPath(basePath, objectId));\r
+ add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
+ if (path != null && path.trim().length() > 0) {\r
+ paths.add(0, PathModel.getParentPath(path, objectId));\r
}\r
\r
final ByteFormat byteFormat = new ByteFormat();\r
// links\r
Fragment links = new Fragment("pathLinks", "treeLinks", this);\r
links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
- links.add(new BookmarkablePageLink<Void>("history", TreePage.class).setEnabled(false));\r
+ links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
item.add(links);\r
} else {\r
// blob link\r
links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
links.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));\r
- links.add(new BookmarkablePageLink<Void>("history", BlobPage.class).setEnabled(false));\r
+ links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));\r
item.add(links);\r
}\r
}\r
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" \r
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" \r
+ xml:lang="en" \r
+ lang="en"> \r
+\r
+<body>\r
+<wicket:panel>\r
+\r
+ <!-- header --> \r
+ <div class="header" wicket:id="header">[history header]</div>\r
+\r
+ <!-- breadcrumbs -->\r
+ <div wicket:id="breadcrumbs">[breadcrumbs]</div>\r
+ \r
+ <table style="width:100%" class="pretty">\r
+ <tbody>\r
+ <tr wicket:id="commit">\r
+ <td class="date"><span wicket:id="commitDate">[commit date]</span></td>\r
+ <td class="author"><span wicket:id="commitAuthor">[commit author]</span></td>\r
+ <td><div wicket:id="commitShortMessage">[commit short message]</div></td>\r
+ <td class="rightAlign"><div wicket:id="commitRefs">[commit refs]</div></td> \r
+ <td class="rightAlign">\r
+ <span class="link">\r
+ <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="commitdiff"><wicket:message key="gb.commitdiff"></wicket:message></a> | <a wicket:id="difftocurrent"><wicket:message key="gb.difftocurrent"></wicket:message></a>\r
+ </span>\r
+ </td>\r
+ </tr>\r
+ </tbody>\r
+ </table> \r
+ <div wicket:id="moreHistory">[more...]</div>\r
+ \r
+</wicket:panel>\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+package com.gitblit.wicket.panels;\r
+\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.repeater.Item;\r
+import org.apache.wicket.markup.repeater.data.DataView;\r
+import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.apache.wicket.model.StringResourceModel;\r
+import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.revwalk.RevCommit;\r
+\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.LinkPanel;\r
+import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.pages.BlobDiffPage;\r
+import com.gitblit.wicket.pages.CommitDiffPage;\r
+import com.gitblit.wicket.pages.CommitPage;\r
+import com.gitblit.wicket.pages.HistoryPage;\r
+import com.gitblit.wicket.pages.LogPage;\r
+\r
+public class HistoryPanel extends BasePanel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+ \r
+ private boolean hasMore = false;\r
+\r
+ public HistoryPanel(String wicketId, final String repositoryName, String objectId, final String path, Repository r, int limit, int pageOffset) {\r
+ super(wicketId);\r
+ boolean pageResults = limit <= 0;\r
+ int itemsPerPage = GitBlit.self().settings().getInteger(Keys.web.logPageCommitCount, 50);\r
+ if (itemsPerPage <= 1) {\r
+ itemsPerPage = 50;\r
+ }\r
+ \r
+ RevCommit commit = JGitUtils.getCommit(r, objectId); \r
+ final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
+ List<RevCommit> commits;\r
+ if (pageResults) {\r
+ // Paging result set\r
+ commits = JGitUtils.getRevLog(r, objectId, path, pageOffset * itemsPerPage, itemsPerPage);\r
+ } else {\r
+ // Fixed size result set\r
+ commits = JGitUtils.getRevLog(r, objectId, path, 0, limit);\r
+ }\r
+ \r
+ // inaccurate way to determine if there are more commits.\r
+ // works unless commits.size() represents the exact end. \r
+ hasMore = commits.size() >= itemsPerPage;\r
+\r
+ // header\r
+ if (pageResults) {\r
+ // history page\r
+ // show commit page link\r
+ add(new LinkPanel("header", "title", commit.getShortMessage(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName())));\r
+ } else {\r
+ // summary page\r
+ // show history page link\r
+ add(new LinkPanel("header", "title", new StringResourceModel("gb.history", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+ }\r
+\r
+ // breadcrumbs\r
+ add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));\r
+\r
+ ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);\r
+ DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {\r
+ private static final long serialVersionUID = 1L;\r
+ int counter = 0;\r
+\r
+ public void populateItem(final Item<RevCommit> item) {\r
+ final RevCommit entry = item.getModelObject();\r
+ final Date date = JGitUtils.getCommitDate(entry);\r
+\r
+ item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone()));\r
+\r
+ String author = entry.getAuthorIdent().getName();\r
+ item.add(WicketUtils.createAuthorLabel("commitAuthor", author));\r
+\r
+ String shortMessage = entry.getShortMessage();\r
+ String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
+ LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()));\r
+ if (!shortMessage.equals(trimmedMessage)) {\r
+ WicketUtils.setHtmlTitle(shortlog, shortMessage);\r
+ }\r
+ item.add(shortlog);\r
+\r
+ item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs));\r
+\r
+ item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ item.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ item.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)).setEnabled(counter > 0));\r
+\r
+ WicketUtils.setAlternatingBackground(item, counter);\r
+ counter++;\r
+ }\r
+ };\r
+ add(logView);\r
+\r
+ // determine to show pager, more, or neither\r
+ if (limit <= 0) {\r
+ // no display limit\r
+ add(new Label("moreHistory", "").setVisible(false));\r
+ } else {\r
+ if (pageResults) {\r
+ // paging\r
+ add(new Label("moreHistory", "").setVisible(false));\r
+ } else {\r
+ // more\r
+ if (commits.size() == limit) {\r
+ // show more\r
+ add(new LinkPanel("moreHistory", "link", new StringResourceModel("gb.moreHistory", this, null), HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path)));\r
+ } else {\r
+ // no more\r
+ add(new Label("moreHistory", "").setVisible(false));\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ public boolean hasMore() {\r
+ return hasMore;\r
+ }\r
+}\r
public class LogPanel extends BasePanel {\r
\r
private static final long serialVersionUID = 1L;\r
+ \r
+ private boolean hasMore = false;\r
\r
public LogPanel(String wicketId, final String repositoryName, String objectId, Repository r, int limit, int pageOffset) {\r
super(wicketId);\r
commits = JGitUtils.getRevLog(r, objectId, 0, limit);\r
}\r
\r
+ // inaccurate way to determine if there are more commits.\r
+ // works unless commits.size() represents the exact end. \r
+ hasMore = commits.size() >= itemsPerPage;\r
+\r
// header\r
if (pageResults) {\r
// shortlog page\r
}\r
}\r
}\r
+ \r
+ public boolean hasMore() {\r
+ return hasMore;\r
+ }\r
}\r