代码之家  ›  专栏  ›  技术社区  ›  Federer

使用SVNKit签出目录/文件

  •  8
  • Federer  · 技术社区  · 14 年前

    我在维基上看不到记录签出的地方。理想情况下,我想签出一个文件“example/folder/file.xml”,如果不仅仅是文件夹。。。然后当应用程序关闭或以其他方式关闭时,可以提交回对此文件的更改。我该怎么做?

    3 回复  |  直到 7 年前
        1
  •  8
  •   Jasper wontondon    12 年前

    不能在Subversion中签出文件。你必须签出一个文件夹。

    要签出包含一个或多个文件的文件夹,请执行以下操作:

    SVNClientManager ourClientManager = SVNClientManager.newInstance(null, 
                repository.getAuthenticationManager());
    SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
    updateClient.setIgnoreExternals(false);
    updateClient.doCheckout(url, destPath, revision, revision,
                isRecursive);
    

    SVNClientManager ourClientManager = SVNClientManager.newInstance(null, 
                repository.getAuthenticationManager());
    ourClientManager.getWCClient().doInfo(wcPath, SVNRevision.HEAD);
    ourClientManager.getCommitClient().doCommit
            (new File[] { wcPath }, keepLocks, commitMessage, false, true);
    
        2
  •  19
  •   Dmitry Pavlenko    12 年前

    作为SVNKit开发人员,我建议您更喜欢基于SvnOperationFactory的新API。旧的API(基于SVNClientManager)仍然可以运行,但是所有新的SVN特性只会出现在新的API中。

    final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
    try {
        final SvnCheckout checkout = svnOperationFactory.createCheckout();
        checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory));
        checkout.setSource(SvnTarget.fromURL(url));
        //... other options
        checkout.run();
    } finally {
        svnOperationFactory.dispose();
    }
    
        3
  •  0
  •   Wilfried    8 年前

    但签出或更新35MB的回购结构需要近30分钟。 它在我的用例中不可用(只是将目录结构作为web应用程序的内容/文档/媒体的一部分签出)。

    final ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);
    final SVNURL svnUrl = SVNURL.create(url.getProtocol(), name, url.getHost(), 443, url.getPath(), true);
    
    SVNRepository svnRepo= SVNRepositoryFactory.create(svnUrl);
    svnRepo.setAuthenticationManager(authManager);
    svnOperationFactory.setAuthenticationManager(authManager);
    
    SVNDirEntry entry = svnRepo.info(".", -1);
    long remoteRevision = entry.getRevision();
    
    if (!workingCopyDirectory.exists()) {
        workingCopyDirectory.mkdirs();
    }
    
    final SvnCheckout checkout = svnOperationFactory.createCheckout();
    checkout.setSource(SvnTarget.fromURL(svnUrl));
    checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory));
    remoteRevision = checkout.run();