因此,我在 SVN 存储库下创建了一个项目 TEST,我想知道该项目目录是否与 SVNKit 库一起存在。协议(protocol)是http。
例如,我尝试过...
private String urlSviluppo = "http://myrepo/SVILUPPO";
DAVRepositoryFactory.setup();
SVNURL url = SVNURL.parseURIDecoded(urlSviluppo);
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("user", "pwd");
DAVRepository repositorySviluppo = (DAVRepository)DAVRepositoryFactory.create(url, null);
repositorySviluppo.setAuthenticationManager(authManager);
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager clientManager = SVNClientManager.newInstance(options, "user", "pwd");
clientManager.createRepository(url, true);
如何访问存储库/项目信息?
谢谢
最佳答案
查看 "Printing Out a Subversion Repository Tree" 中的示例。它包含以下代码:
SVNNodeKind nodeKind = repository.checkPath( "" , -1 );
if ( nodeKind == SVNNodeKind.NONE ) {
System.err.println( "There is no entry at '" + url + "'." );
System.exit( 1 );
} else if ( nodeKind == SVNNodeKind.FILE ) {
System.err.println( "The entry at '" + url + "' is a file while a directory was expected." );
System.exit( 1 );
}
这会检查您的位置是否可以作为存储库根目录。
Collection entries = repository.getDir( path, -1 , null , (Collection) null );
Iterator iterator = entries.iterator( );
while ( iterator.hasNext( ) ) {
SVNDirEntry entry = ( SVNDirEntry ) iterator.next( );
...
迭代当前目录的条目。
if ( entry.getKind() == SVNNodeKind.DIR ) {
listEntries( repository, ( path.equals( "" ) ) ? entry.getName( ) : path + "/" + entry.getName( ) );
....
为子目录递归调用它(如果你想访问)。这应该为您提供足够的 Material 来完成整个功能。
关于java - SVNKit - 检查目录是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8271388/