summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPiotr Janik2011-06-06 11:12:48 (EDT)
committer Tomasz Zarna2011-06-06 11:12:48 (EDT)
commitff81d30f0f9af1e1bb9912c7ab742b7b307dc385 (patch)
tree0b224fd74576a23d223eaba540778a789368ac75
parent45cba7c9f7d1d2b1537a19d2a25ca51729b0fa7e (diff)
downloadorg.eclipse.orion.server-ff81d30f0f9af1e1bb9912c7ab742b7b307dc385.zip
org.eclipse.orion.server-ff81d30f0f9af1e1bb9912c7ab742b7b307dc385.tar.gz
org.eclipse.orion.server-ff81d30f0f9af1e1bb9912c7ab742b7b307dc385.tar.bz2
bug 344683 - [server] Use LogCommand to get commits list
https://bugs.eclipse.org/bugs/show_bug.cgi?id=344683
-rw-r--r--bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java b/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java
index e3177c9..0b25ab9 100644
--- a/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java
+++ b/bundles/org.eclipse.orion.server.git/src/org/eclipse/orion/server/git/servlets/GitCommitHandlerV1.java
@@ -181,29 +181,35 @@ public class GitCommitHandlerV1 extends ServletResourceHandler<String> {
}
}
- RevWalk walk = new RevWalk(db);
-
+ Git git = new Git(db);
+ LogCommand log = git.log();
// set the commit range
- walk.markStart(walk.lookupCommit(toObjectId));
+ log.add(toObjectId);
if (fromObjectId != null)
- walk.markUninteresting(walk.parseCommit(fromObjectId));
+ log.not(fromObjectId);
// set the path filter
TreeFilter filter = null;
if (path != null && !"".equals(path)) { //$NON-NLS-1$
filter = AndTreeFilter.create(PathFilterGroup.createFromStrings(Collections.singleton(path)), TreeFilter.ANY_DIFF);
- walk.setTreeFilter(filter);
- } else {
- walk.setTreeFilter(TreeFilter.ANY_DIFF);
+ log.addPath(path);
}
- JSONObject result = toJSON(db, OrionServlet.getURI(request), walk, page, filter);
- if (toRefId != null)
- result.put(GitConstants.KEY_REMOTE, BaseToRemoteConverter.getRemoteBranchLocation(getURI(request), Repository.shortenRefName(toRefId.getName()), db, BaseToRemoteConverter.REMOVE_FIRST_3));
- OrionServlet.writeJSONResponse(request, response, result);
- walk.dispose();
- return true;
+ try {
+ Iterable<RevCommit> commits = log.call();
+ JSONObject result = toJSON(db, OrionServlet.getURI(request), commits, page, filter);
+ if (toRefId != null)
+ result.put(GitConstants.KEY_REMOTE, BaseToRemoteConverter.getRemoteBranchLocation(getURI(request), Repository.shortenRefName(toRefId.getName()), db, BaseToRemoteConverter.REMOVE_FIRST_3));
+ OrionServlet.writeJSONResponse(request, response, result);
+ return true;
+ } catch (NoHeadException e) {
+ String msg = NLS.bind("No HEAD reference found when generating log for ref {0}", refIdsRange); //$NON-NLS-1$
+ return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e));
+ } catch (JGitInternalException e) {
+ String msg = NLS.bind("An internal error occured when generating log for ref {0}", refIdsRange); //$NON-NLS-1$
+ return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e));
+ }
}
private JSONObject toJSON(Repository db, URI baseLocation, Iterable<RevCommit> commits, int page, TreeFilter filter) throws JSONException, URISyntaxException, MissingObjectException, IOException {