fix wrong file history view in subversion

This commit is contained in:
Sebastian Sdorra
2011-11-15 21:32:38 +01:00
parent 391df01345
commit afae68a662

View File

@@ -44,6 +44,8 @@ import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
@@ -93,26 +95,6 @@ public class SvnChangesetViewer implements ChangesetViewer
@Override
public ChangesetPagingResult getChangesets(int start, int max)
{
return getChangesets("", null, start, max);
}
/**
* Method description
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*/
@Override
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;
@@ -131,8 +113,8 @@ public class SvnChangesetViewer implements ChangesetViewer
}
List<Changeset> changesetList = new ArrayList<Changeset>();
Collection<SVNLogEntry> entries = repository.log(new String[] { path },
null, startRev, endRev, true, true);
Collection<SVNLogEntry> entries = repository.log(null, null, startRev,
endRev, true, true);
for (SVNLogEntry entry : entries)
{
@@ -154,6 +136,85 @@ public class SvnChangesetViewer implements ChangesetViewer
return changesets;
}
/**
* Method description
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*/
@Override
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
{
ChangesetPagingResult changesets = null;
File directory = handler.getDirectory(repostory);
SVNRepository repository = null;
try
{
repository = SVNRepositoryFactory.create(SVNURL.fromFile(directory));
long startRev = repository.getLatestRevision();
long endRev = 0;
long maxRev = startRev;
if (Util.isNotEmpty(revision))
{
try
{
maxRev = Long.parseLong(revision);
}
catch (NumberFormatException ex)
{
logger.error("could not parse revision ".concat(revision), ex);
}
}
List<Changeset> changesetList = new ArrayList<Changeset>();
Collection<SVNLogEntry> entries = repository.log(new String[] { path },
null, startRev, endRev, true, true);
for (SVNLogEntry entry : entries)
{
if (entry.getRevision() <= maxRev)
{
changesetList.add(SvnUtil.createChangeset(entry));
}
}
int total = changesetList.size();
int end = total - start;
if (end > max)
{
end = max;
}
if (start < 0)
{
start = 0;
}
changesetList = changesetList.subList(start, end);
changesets = new ChangesetPagingResult(total, changesetList);
}
catch (SVNException ex)
{
logger.error("could not open repository", ex);
}
finally
{
repository.closeSession();
}
return changesets;
}
//~--- fields ---------------------------------------------------------------
/** Field description */