SVNKit - 检查目录是否存在

发布于 2024-12-18 05:00:42 字数 756 浏览 4 评论 0原文

因此,我在 SVN 存储库下创建了一个项目 TEST,我想知道该项目目录是否与 SVNKit 库一起存在。协议是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);

如何访问存储库/项目信息?

谢谢

So, I've created a project TEST under an SVN repository and I want to know if this project directory exists with SVNKit library. Protocol is http.

I tried for example...

  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);

how can I access repository/project info ?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满身野味 2024-12-25 05:00:42

查看“打印 Subversion 存储库树” 中的示例。它包含以下代码:

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( ) );
....

对子目录递归调用它(如果你想访问)。这应该为您提供足够的材料来完成整个功能。

Have a look at the example at "Printing Out a Subversion Repository Tree". It contains the following code:

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 );
}

That checks if your location is ok as a repository root.

Collection entries = repository.getDir( path, -1 , null , (Collection) null );
Iterator iterator = entries.iterator( );
while ( iterator.hasNext( ) ) {
     SVNDirEntry entry = ( SVNDirEntry ) iterator.next( );
     ...

Iterate over the entries of the current dir.

if ( entry.getKind() == SVNNodeKind.DIR ) {
    listEntries( repository, ( path.equals( "" ) ) ? entry.getName( ) : path + "/" + entry.getName( ) );
....

Call it recursively for sub-dirs (if you want to visit). This should give you enough material to do the whole function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文