improve performance and memory consumption of svn log command

This commit is contained in:
Sebastian Sdorra
2012-10-13 11:34:18 +02:00
parent 74e5babeab
commit a78c89617a
2 changed files with 32 additions and 8 deletions

View File

@@ -35,6 +35,8 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +50,7 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.util.List;
import java.util.Map;
/**
@@ -72,7 +75,7 @@ public class SvnUtil
* @param entry
*/
public static void appendModification(Modifications modifications,
SVNLogEntryPath entry)
SVNLogEntryPath entry)
{
appendModification(modifications, entry.getType(), entry.getPath());
}
@@ -85,7 +88,7 @@ public class SvnUtil
* @param entry
*/
public static void appendModification(Modifications modifications,
SVNChangeEntry entry)
SVNChangeEntry entry)
{
appendModification(modifications, entry.getType(), entry.getPath());
}
@@ -99,7 +102,7 @@ public class SvnUtil
* @param path
*/
public static void appendModification(Modifications modifications, char type,
String path)
String path)
{
if (path.startsWith("/"))
{
@@ -183,6 +186,26 @@ public class SvnUtil
return changeset;
}
/**
* Method description
*
*
* @param entries
*
* @return
*/
public static List<Changeset> createChangesets(List<SVNLogEntry> entries)
{
List<Changeset> changesets = Lists.newArrayList();
for (SVNLogEntry entry : entries)
{
changesets.add(createChangeset(entry));
}
return changesets;
}
/**
* Method description
*
@@ -217,7 +240,7 @@ public class SvnUtil
* @throws RepositoryException
*/
public static long getRevisionNumber(String revision)
throws RepositoryException
throws RepositoryException
{
long revisionNumber = -1;

View File

@@ -185,7 +185,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
pathArray = new String[] { request.getPath() };
}
List<Changeset> changesetList = Lists.newArrayList();
List<SVNLogEntry> changesetList = Lists.newArrayList();
Collection<SVNLogEntry> entries = repository.log(pathArray, null,
startRev, endRev, true, true);
@@ -193,7 +193,7 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
{
if (entry.getRevision() <= maxRev)
{
changesetList.add(SvnUtil.createChangeset(entry));
changesetList.add(entry);
}
}
@@ -219,8 +219,9 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
start, end, total);
}
changesetList = Lists.newArrayList(changesetList.subList(start, end));
changesets = new ChangesetPagingResult(total, changesetList);
changesetList = changesetList.subList(start, end);
changesets = new ChangesetPagingResult(total,
SvnUtil.createChangesets(changesetList));
}
catch (NumberFormatException ex)
{