1

我有一个目录,其中包含来自旧版构建系统的文件。我想在 SVN 存储库中重新创建此构建系统的时间线。

为此,我必须获取每个构建,提取其所有文件,将它们放在一个合理的目录结构中,将整个目录结构提交给 svn,并为每个构建创建标签(以便轻松识别它们)。现在,我能够从该系统中获取文件,将它们放在一个目录结构中,并且我正在尝试使用 SVNKit 将整个目录放入 SVN(因为整个同步系统是一个使用 Java 代码的系统)。

所以,我要做的是

  1. 使用将所有新文件添加到 svnSVNWCClient.doAdd(main.workDirectory, true, false, false, SVNDepth.INFINITY, false, false /* we only add files below this path */)
  2. 然后使用提交整个目录SVNCommitClient.doCommit(changedFiles, false, null, commitProps, null, false, true, SVNDepth.INFINITY)

不幸的是,它不能很好地工作......

确实,每次我尝试调用这些方法时,我都会得到

Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: Commit failed (details follow):
svn: 'E:\JavaWorkspace\workDirectory\subpath\deep\below\initial\path' is not under version control
and is not part of the commit, 
yet its child is part of the commit
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:85)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:69)
    at org.tmatesoft.svn.core.wc.SVNCommitClient.doCollectCommitItems(SVNCommitClient.java:1236)
    at org.tmatesoft.svn.core.wc.SVNCommitClient.doCommit(SVNCommitClient.java:825)
    at com.perigee.svnsync.SvnExecutor.commit(SvnExecutor.java:229)
    at com.perigee.svnsync.SvnSynchronizer.examineRelease(SvnSynchronizer.java:40)
Caused by: org.tmatesoft.svn.core.SVNException: svn: 'E:\JavaWorkspace\workDirectory\subpath\deep\below\initial\path' is not under version control
and is not part of the commit, 
yet its child is part of the commit
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
    at org.tmatesoft.svn.core.internal.wc.SVNCommitUtil.harvestCommitables(SVNCommitUtil.java:546)
    at org.tmatesoft.svn.core.wc.SVNCommitClient.doCollectCommitItems(SVNCommitClient.java:1208)

请注意,当我使用 TortoiseSVN 查看此文件夹时,它似乎是添加到 SVN 中的完美“普通”文件夹......此外,我可以使用 TortoiseSVn 提交根目录及其所有子目录,而不会出现最小的问题。那么,我可以/应该更改我的代码以使其正常工作吗?

4

1 回答 1

2

事实上,有一个微妙的问题。让我解释一下。

当我调用 时SVNCommitClient.doCommit(changedFiles, false, null, commitProps, null, false, true, SVNDepth.INFINITY),SVNKit 期望我像真正的 svn 命令行客户端一样,将changedFiles提交基目录列表作为 files 数组(第一个参数,)。有关更多信息,请查看svn book

我用那个命令做的事情是精确地在每个文件上直接提交它。不幸的是,因为这是我的第一次提交,那些文件目录还没有在 SVN 中,因此提交失败了。

结果,解决方案是changedFiles用使用的根目录替换,它很简单。

于 2010-10-08T08:59:55.497 回答