mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
implement getChangeset for subversion
This commit is contained in:
@@ -48,8 +48,6 @@ import sonia.scm.util.Util;
|
|||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -93,7 +91,44 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
@Override
|
@Override
|
||||||
public Changeset getChangeset(String revision)
|
public Changeset getChangeset(String revision)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
Changeset changeset = null;
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("fetch changeset {}", revision);
|
||||||
|
}
|
||||||
|
|
||||||
|
SVNRepository repository = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long revisioNumber = Long.parseLong(revision);
|
||||||
|
|
||||||
|
repository = createRepository();
|
||||||
|
|
||||||
|
Collection<SVNLogEntry> entries = repository.log(null, null,
|
||||||
|
revisioNumber, revisioNumber, true,
|
||||||
|
true);
|
||||||
|
|
||||||
|
if (Util.isNotEmpty(entries))
|
||||||
|
{
|
||||||
|
changeset = SvnUtil.createChangeset(entries.iterator().next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("could not convert revision", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SVNException ex) {}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
close(repository);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changeset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,12 +149,11 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChangesetPagingResult changesets = null;
|
ChangesetPagingResult changesets = null;
|
||||||
File directory = handler.getDirectory(repostory);
|
|
||||||
SVNRepository repository = null;
|
SVNRepository repository = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repository = SVNRepositoryFactory.create(SVNURL.fromFile(directory));
|
repository = createRepository();
|
||||||
|
|
||||||
long total = repository.getLatestRevision();
|
long total = repository.getLatestRevision();
|
||||||
long startRev = total - start;
|
long startRev = total - start;
|
||||||
@@ -148,7 +182,7 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
repository.closeSession();
|
close(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changesets;
|
return changesets;
|
||||||
@@ -178,12 +212,11 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChangesetPagingResult changesets = null;
|
ChangesetPagingResult changesets = null;
|
||||||
File directory = handler.getDirectory(repostory);
|
|
||||||
SVNRepository repository = null;
|
SVNRepository repository = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repository = SVNRepositoryFactory.create(SVNURL.fromFile(directory));
|
repository = createRepository();
|
||||||
|
|
||||||
long startRev = repository.getLatestRevision();
|
long startRev = repository.getLatestRevision();
|
||||||
long endRev = 0;
|
long endRev = 0;
|
||||||
@@ -235,12 +268,42 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
repository.closeSession();
|
close(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changesets;
|
return changesets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param repository
|
||||||
|
*/
|
||||||
|
private void close(SVNRepository repository)
|
||||||
|
{
|
||||||
|
if (repository != null)
|
||||||
|
{
|
||||||
|
repository.closeSession();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws SVNException
|
||||||
|
*/
|
||||||
|
private SVNRepository createRepository() throws SVNException
|
||||||
|
{
|
||||||
|
return SVNRepositoryFactory.create(
|
||||||
|
SVNURL.fromFile(handler.getDirectory(repostory)));
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
Reference in New Issue
Block a user