mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
fix wrong file history view in subversion
This commit is contained in:
@@ -44,6 +44,8 @@ import org.tmatesoft.svn.core.SVNURL;
|
|||||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||||
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||||
|
|
||||||
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -93,26 +95,6 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
@Override
|
@Override
|
||||||
public ChangesetPagingResult getChangesets(int start, int max)
|
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;
|
ChangesetPagingResult changesets = null;
|
||||||
File directory = handler.getDirectory(repostory);
|
File directory = handler.getDirectory(repostory);
|
||||||
SVNRepository repository = null;
|
SVNRepository repository = null;
|
||||||
@@ -131,8 +113,8 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Changeset> changesetList = new ArrayList<Changeset>();
|
List<Changeset> changesetList = new ArrayList<Changeset>();
|
||||||
Collection<SVNLogEntry> entries = repository.log(new String[] { path },
|
Collection<SVNLogEntry> entries = repository.log(null, null, startRev,
|
||||||
null, startRev, endRev, true, true);
|
endRev, true, true);
|
||||||
|
|
||||||
for (SVNLogEntry entry : entries)
|
for (SVNLogEntry entry : entries)
|
||||||
{
|
{
|
||||||
@@ -154,6 +136,85 @@ public class SvnChangesetViewer implements ChangesetViewer
|
|||||||
return changesets;
|
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 ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
Reference in New Issue
Block a user