mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
added api to fetch a single changeset
This commit is contained in:
@@ -44,6 +44,18 @@ import java.io.IOException;
|
|||||||
public interface ChangesetViewer
|
public interface ChangesetViewer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @since 1.12
|
||||||
|
*/
|
||||||
|
public Changeset getChangeset(String revision);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import sonia.scm.util.Util;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +95,100 @@ public class ChangesetViewerUtil extends PartCacheClearHook
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @since 1.12
|
||||||
|
*
|
||||||
|
* @throws NotSupportedFeatuerException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
public Changeset getChangeset(Repository repository, String revision)
|
||||||
|
throws RepositoryException, NotSupportedFeatuerException
|
||||||
|
{
|
||||||
|
AssertUtil.assertIsNotNull(repository);
|
||||||
|
|
||||||
|
ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);
|
||||||
|
|
||||||
|
if (viewer == null)
|
||||||
|
{
|
||||||
|
throw new NotSupportedFeatuerException(
|
||||||
|
"ChangesetViewer is not supported for type ".concat(
|
||||||
|
repository.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Changeset changeset = null;
|
||||||
|
ChangesetViewerCacheKey key =
|
||||||
|
new ChangesetViewerCacheKey(repository.getId(), -1, -1);
|
||||||
|
ChangesetPagingResult result = cache.get(key);
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
changeset = viewer.getChangeset(revision);
|
||||||
|
|
||||||
|
if (changeset != null)
|
||||||
|
{
|
||||||
|
callPreProcessors(changeset);
|
||||||
|
callPreProcessorFactories(repository, changeset);
|
||||||
|
result = new ChangesetPagingResult(1, Arrays.asList(changeset));
|
||||||
|
cache.put(key, result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new RepositoryException("could not find changeset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("fetch changesetviewer result from cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
changeset = result.getChangesets().get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changeset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repositoryId
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @since 1.12
|
||||||
|
*
|
||||||
|
* @throws NotSupportedFeatuerException
|
||||||
|
* @throws RepositoryException
|
||||||
|
* @throws RepositoryNotFoundException
|
||||||
|
*/
|
||||||
|
public Changeset getChangeset(String repositoryId, String revision)
|
||||||
|
throws RepositoryNotFoundException, RepositoryException,
|
||||||
|
NotSupportedFeatuerException
|
||||||
|
{
|
||||||
|
AssertUtil.assertIsNotEmpty(repositoryId);
|
||||||
|
|
||||||
|
Repository repository = repositoryManager.get(repositoryId);
|
||||||
|
|
||||||
|
if (repository == null)
|
||||||
|
{
|
||||||
|
throw new RepositoryNotFoundException(
|
||||||
|
"could not find repository with id ".concat(repositoryId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return getChangeset(repository, revision);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -316,6 +411,30 @@ public class ChangesetViewerUtil extends PartCacheClearHook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
* @param c
|
||||||
|
*/
|
||||||
|
private void callPreProcessorFactories(Repository repository, Changeset c)
|
||||||
|
{
|
||||||
|
if (Util.isNotEmpty(changesetPreProcessorFactorySet))
|
||||||
|
{
|
||||||
|
for (ChangesetPreProcessorFactory factory :
|
||||||
|
changesetPreProcessorFactorySet)
|
||||||
|
{
|
||||||
|
ChangesetPreProcessor cpp = factory.createPreProcessor(repository);
|
||||||
|
|
||||||
|
if (cpp != null)
|
||||||
|
{
|
||||||
|
cpp.process(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -327,14 +446,25 @@ public class ChangesetViewerUtil extends PartCacheClearHook
|
|||||||
if (Util.isNotEmpty(changesetPreProcessorSet))
|
if (Util.isNotEmpty(changesetPreProcessorSet))
|
||||||
{
|
{
|
||||||
for (Changeset c : changesets.getChangesets())
|
for (Changeset c : changesets.getChangesets())
|
||||||
|
{
|
||||||
|
callPreProcessors(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
*/
|
||||||
|
private void callPreProcessors(Changeset c)
|
||||||
{
|
{
|
||||||
for (ChangesetPreProcessor cpp : changesetPreProcessorSet)
|
for (ChangesetPreProcessor cpp : changesetPreProcessorSet)
|
||||||
{
|
{
|
||||||
cpp.process(c);
|
cpp.process(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//~--- inner classes --------------------------------------------------------
|
//~--- inner classes --------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,20 @@ public class GitChangesetViewer implements ChangesetViewer
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Changeset getChangeset(String revision)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import com.google.inject.Singleton;
|
|||||||
import org.eclipse.jgit.storage.file.FileRepository;
|
import org.eclipse.jgit.storage.file.FileRepository;
|
||||||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
|
||||||
|
|
||||||
import sonia.scm.NotSupportedFeatuerException;
|
|
||||||
import sonia.scm.Type;
|
import sonia.scm.Type;
|
||||||
import sonia.scm.io.FileSystem;
|
import sonia.scm.io.FileSystem;
|
||||||
import sonia.scm.plugin.ext.Extension;
|
import sonia.scm.plugin.ext.Extension;
|
||||||
|
|||||||
@@ -103,6 +103,20 @@ public class HgChangesetViewer extends AbstractHgHandler
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Changeset getChangeset(String revision)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -82,6 +82,20 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param revision
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Changeset getChangeset(String revision)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user