Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用SVNKit签出目录/文件_Java_Svnkit - Fatal编程技术网

Java 使用SVNKit签出目录/文件

Java 使用SVNKit签出目录/文件,java,svnkit,Java,Svnkit,我在维基上看不到记录签出的地方。理想情况下,我想签出一个文件“example/folder/file.xml”,如果不仅仅是文件夹。。。然后,当应用程序关闭或以其他方式关闭时,可以将更改提交回该文件。如何执行此操作?您无法在Subversion中签出文件。你必须签出一个文件夹 要签出包含一个或多个文件的文件夹,请执行以下操作: SVNClientManager-ourClientManager=SVNClientManager.newInstance(null, getAuthenticatio

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

您无法在Subversion中签出文件。你必须签出一个文件夹

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

SVNClientManager-ourClientManager=SVNClientManager.newInstance(null,
getAuthenticationManager());
SVNUpdateClient updateClient=ourClientManager.getUpdateClient();
updateClient.setIgnoreExternals(false);
updateClient.doCheckout(url,destPath,revision,revision,
执行性);
要提交以前签出的文件夹,请执行以下操作:

SVNClientManager-ourClientManager=SVNClientManager.newInstance(null,
getAuthenticationManager());
ourClientManager.getWCClient().doInfo(wcPath,SVNRevision.HEAD);
ourClientManager.getCommitClient().doCommit
(新文件[]{wcPath},keepLocks,commitMessage,false,true);

作为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();
}

我还使用了Dmitry Pavlenko提出的代码片段,没有任何问题。 但签出或更新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();

+一个非常有用的答案。此外,如果要导出文件,则可以使用SVNKit 1.7.5-v1中不推荐使用的doExport中列出的重载进行导出。相反,我使用了以下重载:
updateClient.doCheckout(url、destPath、SVNRevision.HEAD、SVNRevision.HEAD、SVNDepth.INFINITY、true)
在使用上述代码时,我收到一条警告“来自SVNUpdateClient类型的方法doCheckout(SVNURL,File,SVNRevision,SVNRevision,boolean)已被弃用”…知道使用哪种方法代替doCheckout吗?因此我们必须将workingCopyDirectory声明为“File workingCopyDirectory=new File(“/home/lucy”)???好的..我还有一个疑问..SvnOperationFactory是否会复制文件夹以及存储在特定SVN路径中的文件或仅复制文件?其行为方式与
SVN co
相同:
workingCopyDirectory
将包含与
url
相同的文件和目录。我已使用上述代码两次来从svn签出2个目录。有更好的方法吗?没有,没有办法在一次操作中签出多个工作副本。我也有同样的问题,它需要花费很长时间才能完成。。。必须缺少一个参数。你解决过吗?