Search in sources :

Example 1 with SVNDirEntry

use of org.tmatesoft.svn.core.SVNDirEntry in project intellij-community by JetBrains.

the class SvnProtocolsTest method testBrowseRepositoryImpl.

private void testBrowseRepositoryImpl(final String url) throws SVNException {
    final List<SVNDirEntry> list = new ArrayList<>();
    final SVNRepository repository = myVcs.getSvnKitManager().createRepository(url);
    repository.getDir(".", -1, null, dirEntry -> list.add(dirEntry));
    Assert.assertTrue(!list.isEmpty());
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) ArrayList(java.util.ArrayList) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository)

Example 2 with SVNDirEntry

use of org.tmatesoft.svn.core.SVNDirEntry in project intellij-community by JetBrains.

the class SvnNativeClientAuthTest method testBrowseRepositoryImpl.

private void testBrowseRepositoryImpl(final String url) throws SVNException {
    final List<SVNDirEntry> list = new ArrayList<>();
    final SVNRepository repository = myVcs.getSvnKitManager().createRepository(url);
    repository.getDir(".", -1, null, dirEntry -> list.add(dirEntry));
    Assert.assertTrue(!list.isEmpty());
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) ArrayList(java.util.ArrayList) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository)

Example 3 with SVNDirEntry

use of org.tmatesoft.svn.core.SVNDirEntry in project Gargoyle by callakrsos.

the class CommandTest3 method scenarioTest.

/**
	 *
	 * ################# 시나리오 테스트 ###################
	 *
	 * 1. svn 디렉토리 파일목록만 추출.
	 *
	 * 2. 추출된 파일목록에서 컨텐츠 조회
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 5. 13.
	 */
@Test
public void scenarioTest() {
    List<SVNDirEntry> list = testServerManager.listEntry("/sos/pass-batch-core");
    Optional<String> findFirst = list.stream().filter(e -> {
        SVNNodeKind kind = e.getKind();
        if (SVNNodeKind.FILE == kind)
            return true;
        return false;
    }).map(e -> {
        try {
            SVNURL url = e.getURL();
            SVNURL repositoryRoot = e.getRepositoryRoot();
            String relativeURL = SVNURLUtil.getRelativeURL(repositoryRoot, url, true);
            return relativeURL;
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return "error";
    }).peek(e -> {
        System.out.println(testServerManager.cat(e));
    }).findFirst();
    // 첫번째 데이터를 찾은후...
    findFirst.ifPresent(url -> {
        try {
            File outDir = new File("c://sampleDir");
            outDir.mkdir();
            System.out.println("checout dir ::: " + outDir.getAbsolutePath());
            System.out.println("checout url ::: " + url);
            Long checkout = testServerManager.checkout(url, outDir);
            System.out.println("result ::: " + checkout);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    });
}
Also used : Date(java.util.Date) JavaSVNManager(com.kyj.scm.manager.svn.java.JavaSVNManager) SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) Locale(java.util.Locale) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) ParseException(java.text.ParseException) Before(org.junit.Before) ProxyInitializable(com.kyj.fx.voeditor.visual.main.initalize.ProxyInitializable) Properties(java.util.Properties) SVNURLUtil(org.tmatesoft.svn.core.internal.util.SVNURLUtil) SVNException(org.tmatesoft.svn.core.SVNException) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) FileWriter(java.io.FileWriter) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) SVNCommitInfo(org.tmatesoft.svn.core.SVNCommitInfo) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SVNURL(org.tmatesoft.svn.core.SVNURL) Optional(java.util.Optional) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) Assert(org.junit.Assert) SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) SVNURL(org.tmatesoft.svn.core.SVNURL) File(java.io.File) ParseException(java.text.ParseException) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.Test)

Example 4 with SVNDirEntry

use of org.tmatesoft.svn.core.SVNDirEntry in project Gargoyle by callakrsos.

the class SVNList method list.

/********************************
	 * 작성일 : 2016. 5. 4. 작성자 : KYJ
	 *
	 * path에 속하는 구성정보 조회
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public List<String> list(String path, String revision, Consumer<Exception> exceptionHandler) {
    List<String> resultList = Collections.emptyList();
    try {
        SVNProperties fileProperties = new SVNProperties();
        SVNRepository repository = getRepository();
        Collection<SVNDirEntry> dir = repository.getDir(path, Long.parseLong(revision), fileProperties, new ArrayList<>());
        resultList = dir.stream().map(d -> {
            SVNNodeKind kind = d.getKind();
            if (SVNNodeKind.DIR == kind) {
                return d.getRelativePath().concat("/");
            } else {
                return d.getRelativePath();
            }
        }).collect(Collectors.toList());
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return resultList;
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) SVNProperties(org.tmatesoft.svn.core.SVNProperties) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException)

Example 5 with SVNDirEntry

use of org.tmatesoft.svn.core.SVNDirEntry in project Gargoyle by callakrsos.

the class SVNList method listEntry.

/********************************
	 * 작성일 : 2016. 5. 9. 작성자 : KYJ
	 *
	 * 메타정보를 포함하는 SVN 엔트리 반환
	 *
	 * 2016-11-03 버그 수정
	 *
	 * @param path
	 * @param revision
	 * @param exceptionHandler
	 * @return
	 ********************************/
public List<SVNDirEntry> listEntry(String path, String revision, boolean isRecursive, Consumer<Exception> exceptionHandler) {
    List<SVNDirEntry> resultList = new LinkedList<>();
    try {
        SVNRepository repository = getRepository();
        long parseLong = Long.parseLong(revision, 10);
        List<SVNDirEntry> list = new ArrayList<>();
        String _path = path;
        try {
            _path = URLDecoder.decode(_path, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        repository.getDir(_path, parseLong, true, list);
        if (isRecursive) {
            Iterator<SVNDirEntry> iterator = list.iterator();
            while (iterator.hasNext()) {
                SVNDirEntry entry = iterator.next();
                if (entry.getKind() == SVNNodeKind.DIR) {
                    SVNURL url = entry.getURL();
                    List<SVNDirEntry> listEntry = listEntry(url.getPath(), revision, isRecursive, exceptionHandler);
                    resultList.addAll(listEntry);
                } else {
                    resultList.add(entry);
                }
            }
        } else {
            resultList.addAll(list);
        }
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return resultList;
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) SVNURL(org.tmatesoft.svn.core.SVNURL) ArrayList(java.util.ArrayList) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException) LinkedList(java.util.LinkedList) SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)9 SVNException (org.tmatesoft.svn.core.SVNException)6 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)6 ArrayList (java.util.ArrayList)4 SVNURL (org.tmatesoft.svn.core.SVNURL)4 JavaSVNManager (com.kyj.scm.manager.svn.java.JavaSVNManager)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 SVNNodeKind (org.tmatesoft.svn.core.SVNNodeKind)2 ProxyInitializable (com.kyj.fx.voeditor.visual.main.initalize.ProxyInitializable)1 DateUtil (com.kyj.fx.voeditor.visual.util.DateUtil)1 FileUtil (com.kyj.fx.voeditor.visual.util.FileUtil)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1