added missing revision parameter to changesetviewer api

This commit is contained in:
Sebastian Sdorra
2011-11-15 20:45:37 +01:00
parent f6b83ba815
commit c609df47ef
8 changed files with 114 additions and 31 deletions

View File

@@ -68,6 +68,7 @@ public interface ChangesetViewer
*
*
* @param path
* @param revision
* @param start
* @param max
*
@@ -76,6 +77,7 @@ public interface ChangesetViewer
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String path, int start, int max)
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
throws IOException, RepositoryException;
}

View File

@@ -132,6 +132,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
*
* @param repositoryId
* @param path
* @param revision
* @param start
* @param max
*
@@ -143,7 +144,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String repositoryId, String path,
int start, int max)
String revision, int start, int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotEmpty(repositoryId);
@@ -156,7 +157,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
"could not find repository with id ".concat(repositoryId));
}
return getChangesets(repository, path, start, max);
return getChangesets(repository, path, revision, start, max);
}
/**
@@ -190,8 +191,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
}
ChangesetViewerCacheKey key =
new ChangesetViewerCacheKey(repository.getId(), Util.EMPTY_STRING, start,
max);
new ChangesetViewerCacheKey(repository.getId(), start, max);
ChangesetPagingResult result = cache.get(key);
if (result == null)
@@ -227,6 +227,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
*
* @param repository
* @param path
* @param revision
* @param start
* @param max
*
@@ -238,7 +239,7 @@ public class ChangesetViewerUtil extends PartCacheClearHook
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(Repository repository,
String path, int start, int max)
String path, String revision, int start, int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotNull(repository);
@@ -253,12 +254,13 @@ public class ChangesetViewerUtil extends PartCacheClearHook
}
ChangesetViewerCacheKey key =
new ChangesetViewerCacheKey(repository.getId(), path, start, max);
new ChangesetViewerCacheKey(repository.getId(), path, revision, start,
max);
ChangesetPagingResult result = cache.get(key);
if (result == null)
{
result = viewer.getChangesets(path, start, max);
result = viewer.getChangesets(path, revision, start, max);
if (result != null)
{
@@ -351,15 +353,30 @@ public class ChangesetViewerUtil extends PartCacheClearHook
*
*
* @param repository
* @param path
* @param start
* @param max
*/
public ChangesetViewerCacheKey(String repository, String path, int start,
int max)
public ChangesetViewerCacheKey(String repository, int start, int max)
{
this(repository, null, null, start, max);
}
/**
* Constructs ...
*
*
* @param repository
* @param path
* @param revision
* @param start
* @param max
*/
public ChangesetViewerCacheKey(String repository, String path,
String revision, int start, int max)
{
this.repository = repository;
this.path = path;
this.revision = revision;
this.start = start;
this.max = max;
}
@@ -389,6 +406,13 @@ public class ChangesetViewerUtil extends PartCacheClearHook
final ChangesetViewerCacheKey other = (ChangesetViewerCacheKey) obj;
if ((this.revision == null)
? (other.revision != null)
: !this.revision.equals(other.revision))
{
return false;
}
if (this.max != other.max)
{
return false;
@@ -425,16 +449,19 @@ public class ChangesetViewerUtil extends PartCacheClearHook
@Override
public int hashCode()
{
int hash = 7;
int hash = 5;
hash = 89 * hash + this.max;
hash = 89 * hash + ((this.path != null)
hash = 47 * hash + ((this.revision != null)
? this.revision.hashCode()
: 0);
hash = 47 * hash + this.max;
hash = 47 * hash + ((this.path != null)
? this.path.hashCode()
: 0);
hash = 89 * hash + ((this.repository != null)
hash = 47 * hash + ((this.repository != null)
? this.repository.hashCode()
: 0);
hash = 89 * hash + this.start;
hash = 47 * hash + this.start;
return hash;
}
@@ -464,6 +491,9 @@ public class ChangesetViewerUtil extends PartCacheClearHook
/** Field description */
private String repository;
/** Field description */
private String revision;
/** Field description */
private int start;
}

View File

@@ -155,13 +155,15 @@ public class GitChangesetViewer implements ChangesetViewer
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*/
@Override
public ChangesetPagingResult getChangesets(String path, int start, int max)
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
{
ChangesetPagingResult changesets = null;
File directory = handler.getDirectory(repository);
@@ -180,11 +182,12 @@ public class GitChangesetViewer implements ChangesetViewer
converter = new GitChangesetConverter(gr, GitUtil.ID_LENGTH);
Git git = new Git(gr);
ObjectId headId = GitUtil.getRepositoryHead(gr);
ObjectId revisionId = GitUtil.getRevisionId(gr, revision);
if (headId != null)
if (revisionId != null)
{
for (RevCommit commit : git.log().addPath(path).call())
for (RevCommit commit :
git.log().add(revisionId).addPath(path).call())
{
if ((counter >= start) && (counter < start + max))
{

View File

@@ -399,6 +399,7 @@ public class AbstractHgHandler
}
msg.append("]");
logger.debug(msg.toString());
}
ProcessBuilder pb = new ProcessBuilder(cmdList);

View File

@@ -35,7 +35,11 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.Util;
import sonia.scm.web.HgUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -58,6 +62,10 @@ public class HgChangesetViewer extends AbstractHgHandler
/** Field description */
public static final String RESOURCE_LOG = "/sonia/scm/hglog.py";
/** the logger for HgChangesetViewer */
private static final Logger logger =
LoggerFactory.getLogger(HgChangesetViewer.class);
//~--- constructors ---------------------------------------------------------
/**
@@ -110,6 +118,11 @@ public class HgChangesetViewer extends AbstractHgHandler
public ChangesetPagingResult getChangesets(int start, int max)
throws IOException, RepositoryException
{
if (logger.isDebugEnabled())
{
logger.debug("fetch changesets. start: {}, max: {}", start, max);
}
return getChangesets(null, null, String.valueOf(start),
String.valueOf(max), null, null);
}
@@ -119,6 +132,7 @@ public class HgChangesetViewer extends AbstractHgHandler
*
*
* @param path
* @param revision
* @param start
* @param max
*
@@ -128,10 +142,21 @@ public class HgChangesetViewer extends AbstractHgHandler
* @throws RepositoryException
*/
@Override
public ChangesetPagingResult getChangesets(String path, int start, int max)
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
throws IOException, RepositoryException
{
return getChangesets(path, null, String.valueOf(start),
revision = HgUtil.getRevision(revision);
if (logger.isDebugEnabled())
{
logger.debug(
"fetch changesets for path {} and revision {}. start: {}, max: {}",
new Object[] { path,
revision, start, max });
}
return getChangesets(path, revision, String.valueOf(start),
String.valueOf(max), null, null);
}
@@ -184,6 +209,12 @@ public class HgChangesetViewer extends AbstractHgHandler
public ChangesetPagingResult getChangesets(String startNode, String endNode)
throws IOException, RepositoryException
{
if (logger.isDebugEnabled())
{
logger.debug("fetch changesets. start-node: {}, end-node: {}", startNode,
endNode);
}
return getChangesets(null, null, null, null, startNode, endNode);
}
}

View File

@@ -93,7 +93,7 @@ public class SvnChangesetViewer implements ChangesetViewer
@Override
public ChangesetPagingResult getChangesets(int start, int max)
{
return getChangesets("", start, max);
return getChangesets("", null, start, max);
}
/**
@@ -101,13 +101,18 @@ public class SvnChangesetViewer implements ChangesetViewer
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*/
@Override
public ChangesetPagingResult getChangesets(String path, int start, int max) {
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
{
// TODO implement revision
ChangesetPagingResult changesets = null;
File directory = handler.getDirectory(repostory);
SVNRepository repository = null;
@@ -148,6 +153,7 @@ public class SvnChangesetViewer implements ChangesetViewer
return changesets;
}
//~--- fields ---------------------------------------------------------------
/** Field description */

View File

@@ -424,6 +424,7 @@ public class RepositoryResource
*
* @param id the id of the repository
* @param path path of a file
* @param revision the revision of the file specified by the path parameter
* @param start the start value for paging
* @param limit the limit value for paging
*
@@ -438,6 +439,7 @@ public class RepositoryResource
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getChangesets(@PathParam("id") String id,
@QueryParam("path") String path,
@QueryParam("revision") String revision,
@DefaultValue("0")
@QueryParam("start") int start, @DefaultValue("20")
@QueryParam("limit") int limit) throws RepositoryException, IOException
@@ -454,7 +456,8 @@ public class RepositoryResource
}
else
{
changesets = changesetViewerUtil.getChangesets(id, path, start, limit);
changesets = changesetViewerUtil.getChangesets(id, path, revision,
start, limit);
}
if (changesets != null)

View File

@@ -36,8 +36,11 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
pageSize: 20,
historyId: null,
changesetStore: null,
path: null,
// parameters for file history view
inline: false,
path: null,
revision: null,
changesetViewerTitleText: 'Commits {0}',
@@ -62,6 +65,10 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
params.path = this.path;
}
if (this.revision){
params.revision = this.revision;
}
this.changesetStore = new Sonia.rest.JsonStore({
id: 'changesetStore',
proxy: new Ext.data.HttpProxy({