fix wrong svn blame revision

This commit is contained in:
Sebastian Sdorra
2011-09-15 13:54:14 +02:00
parent 4644af0580
commit 4c2b9a66e2
2 changed files with 26 additions and 10 deletions

View File

@@ -122,11 +122,18 @@ public class SvnBlameHandler implements ISVNAnnotateHandler
if (Util.isNotEmpty(author))
{
authorPerson = new Person(author);
authorPerson = Person.toPerson(author);
}
blameLines.add(new BlameLine(authorPerson, date.getTime(),
String.valueOf(revision), line, lineNumber));
Long when = null;
if (date != null)
{
when = date.getTime();
}
blameLines.add(new BlameLine(authorPerson, when, String.valueOf(revision),
line, lineNumber));
}
/**

View File

@@ -45,6 +45,8 @@ import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNLogClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
@@ -95,11 +97,20 @@ public class SvnBlameViewer implements BlameViewer
@Override
public BlamePagingResult getBlame(String revision, String path)
{
final List<BlameLine> blameLines = new ArrayList<BlameLine>();
List<BlameLine> blameLines = new ArrayList<BlameLine>();
File directory = handler.getDirectory(repository);
SVNRepository svnRepository = null;
SVNURL svnurl = null;
int total = 0;
SVNRevision endRevision = null;
if (Util.isNotEmpty(revision))
{
endRevision = SVNRevision.create(Long.parseLong(revision));
}
else
{
endRevision = SVNRevision.HEAD;
}
try
{
@@ -110,8 +121,8 @@ public class SvnBlameViewer implements BlameViewer
svnRepository.getAuthenticationManager();
SVNLogClient svnLogClient = new SVNLogClient(svnManager, null);
svnLogClient.doAnnotate(svnurl, SVNRevision.HEAD, SVNRevision.HEAD,
SVNRevision.HEAD,
svnLogClient.doAnnotate(svnurl, SVNRevision.UNDEFINED,
SVNRevision.create(1l), endRevision,
new SvnBlameHandler(blameLines));
}
catch (Exception ex)
@@ -119,9 +130,7 @@ public class SvnBlameViewer implements BlameViewer
logger.error("could not create blame view", ex);
}
total = blameLines.get(blameLines.size() - 1).getLineNumber();
return new BlamePagingResult(total, blameLines);
return new BlamePagingResult(blameLines.size(), blameLines);
}
//~--- fields ---------------------------------------------------------------