使用SVNKit检出目录/文件

Fed*_*rer 8 java svnkit

我无法在维基上看到记录结果的位置.理想情况下,我想查看文件"example/folder/file.xml",如果不仅仅是文件夹...然后当应用程序关闭或以其他方式时,能够提交回更改此文件.我该怎么做呢?

Dmi*_*nko 19

作为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();
}
Run Code Online (Sandbox Code Playgroud)


Gil*_*anc 8

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

要签出包含一个或多个文件的文件夹:

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

提交先前签出的文件夹:

SVNClientManager ourClientManager = SVNClientManager.newInstance(null, 
            repository.getAuthenticationManager());
ourClientManager.getWCClient().doInfo(wcPath, SVNRevision.HEAD);
ourClientManager.getCommitClient().doCommit
        (new File[] { wcPath }, keepLocks, commitMessage, false, true);
Run Code Online (Sandbox Code Playgroud)