use of org.tmatesoft.svn.core.wc.SVNLogClient in project Gargoyle by callakrsos.
the class SVNLog method logFileSystem.
/********************************
* 작성일 : 2016. 7. 13. 작성자 : KYJ
*
*
* @param path
* @param startRevision
* @param endDate
* @param exceptionHandler
* @return
********************************/
public List<SVNLogEntry> logFileSystem(File[] path, long startRevision, Date endDate, Consumer<Exception> exceptionHandler) {
SVNLogClient logClient = getSvnManager().getLogClient();
List<SVNLogEntry> result = new ArrayList<>();
try {
ISVNLogEntryHandler handler = logEntry -> {
LOGGER.debug("path :: {} rivision :: {} date :: {} author :: {} message :: {} ", path, logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
result.add(logEntry);
};
doLog(path, startRevision, endDate, logClient, handler);
} catch (SVNException e) {
LOGGER.error(ValueUtil.toString(e));
if (exceptionHandler != null)
exceptionHandler.accept(e);
}
return result;
}
use of org.tmatesoft.svn.core.wc.SVNLogClient in project Gargoyle by callakrsos.
the class SVNLog method log.
/********************************
* 작성일 : 2016. 5. 5. 작성자 : KYJ
*
* 이력정보 조회
*
* @param path
* 상대경로
* @param revision
* 리비젼번호
* @param exceptionHandler
* 에러발생시 처리할 핸들 정의
* @return
********************************/
public List<SVNLogEntry> log(String path, String revision, Consumer<Exception> exceptionHandler) {
SVNLogClient logClient = getSvnManager().getLogClient();
List<SVNLogEntry> result = new ArrayList<>();
try {
ISVNLogEntryHandler handler = logEntry -> {
LOGGER.debug("rivision :: {} date :: {} author :: {} message :: {} ", logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
result.add(logEntry);
};
String _path = path;
try {
_path = URLDecoder.decode(_path, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
logClient.doLog(getSvnURL(), new String[] { _path }, SVNRevision.create(Long.parseLong(revision)), SVNRevision.create(Long.parseLong(revision) == -1 ? 0 : Long.parseLong(revision)), SVNRevision.HEAD, true, false, 100L, handler);
} catch (SVNException e) {
if (exceptionHandler != null)
exceptionHandler.accept(e);
else
LOGGER.error(ValueUtil.toString(e));
}
return result;
}
use of org.tmatesoft.svn.core.wc.SVNLogClient in project sonarqube by SonarSource.
the class SvnScmProvider method branchChangedLines.
@CheckForNull
@Override
public Map<Path, Set<Integer>> branchChangedLines(String targetBranchName, Path rootBaseDir, Set<Path> changedFiles) {
SVNClientManager clientManager = null;
try {
clientManager = newSvnClientManager(configuration);
// find reference revision number: the copy point
SVNLogClient svnLogClient = clientManager.getLogClient();
long[] revisionCounter = { 0 };
svnLogClient.doLog(new File[] { rootBaseDir.toFile() }, null, null, null, true, true, 0, svnLogEntry -> revisionCounter[0] = svnLogEntry.getRevision());
long startRev = revisionCounter[0];
SVNDiffClient svnDiffClient = clientManager.getDiffClient();
File path = rootBaseDir.toFile();
ChangedLinesComputer computer = newChangedLinesComputer(rootBaseDir, changedFiles);
svnDiffClient.doDiff(path, SVNRevision.create(startRev), path, SVNRevision.WORKING, SVNDepth.INFINITY, false, computer.receiver(), null);
return computer.changedLines();
} catch (Exception e) {
LOG.warn("Failed to get changed lines from Subversion", e);
} finally {
if (clientManager != null) {
try {
clientManager.dispose();
} catch (Exception e) {
LOG.warn("Unable to dispose SVN ClientManager", e);
}
}
}
return null;
}
use of org.tmatesoft.svn.core.wc.SVNLogClient in project sonarqube by SonarSource.
the class SvnBlameCommandTest method blame_givenCredentialsSupplied_doNotlogWarning.
@Test
public void blame_givenCredentialsSupplied_doNotlogWarning() throws Exception {
BlameOutput output = mock(BlameOutput.class);
InputFile inputFile = mock(InputFile.class);
SvnConfiguration properties = mock(SvnConfiguration.class);
SvnBlameCommand svnBlameCommand = new SvnBlameCommand(properties);
SVNClientManager clientManager = mock(SVNClientManager.class);
SVNLogClient logClient = mock(SVNLogClient.class);
SVNStatusClient statusClient = mock(SVNStatusClient.class);
SVNStatus status = mock(SVNStatus.class);
when(properties.isEmpty()).thenReturn(true);
when(clientManager.getLogClient()).thenReturn(logClient);
when(clientManager.getStatusClient()).thenReturn(statusClient);
when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
when(inputFile.file()).thenReturn(mock(File.class));
when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
assertThrows(IllegalStateException.class, () -> {
svnBlameCommand.blame(clientManager, inputFile, output);
assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
});
}
use of org.tmatesoft.svn.core.wc.SVNLogClient in project sonarqube by SonarSource.
the class SvnBlameCommandTest method blame_givenNoCredentials_logWarning.
@Test
public void blame_givenNoCredentials_logWarning() throws Exception {
BlameOutput output = mock(BlameOutput.class);
InputFile inputFile = mock(InputFile.class);
SvnBlameCommand svnBlameCommand = newSvnBlameCommand();
SVNClientManager clientManager = mock(SVNClientManager.class);
SVNLogClient logClient = mock(SVNLogClient.class);
SVNStatusClient statusClient = mock(SVNStatusClient.class);
SVNStatus status = mock(SVNStatus.class);
when(clientManager.getLogClient()).thenReturn(logClient);
when(clientManager.getStatusClient()).thenReturn(statusClient);
when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
when(inputFile.file()).thenReturn(mock(File.class));
when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
assertThrows(IllegalStateException.class, () -> {
svnBlameCommand.blame(clientManager, inputFile, output);
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Authentication to SVN server is required but no " + "authentication data was passed to the scanner");
});
}
Aggregations