SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
2014-01-06 16:38
441 查看
弄了很久,想使用domove这个操作,但是都失败了。最后给svnkit的邮箱写了封邮件,他们告诉我这样做就成功了。实际上是使用docopy这个函数实现了move操作。 package com.repositoryclient.svnoptions; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.ISVNOptions; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNCopyClient; import org.tmatesoft.svn.core.wc.SVNCopySource; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCUtil; public class StoreManagerCheckResourceOption { private SVNRepository repositoryTrgt; private SVNRepository repositorySrc; public boolean doMove(String userName,String passwd,String sourceDirUrl,String targetDirUrl){ SVNClientManager ourClientManager; // 初始化支持svn://协议的库 SVNRepositoryFactoryImpl.setup(); DAVRepositoryFactory.setup(); FSRepositoryFactory.setup(); SVNURL repositorySrcUrl = null; SVNURL repositoryTrgtUrl = null; try { SVNWCUtil.createDefaultAuthenticationManager(userName,passwd); repositorySrcUrl = SVNURL.parseURIEncoded(sourceDirUrl); repositoryTrgtUrl = SVNURL.parseURIEncoded(targetDirUrl); repositorySrc = SVNRepositoryFactory.create(repositorySrcUrl); repositoryTrgt = SVNRepositoryFactory.create(repositoryTrgtUrl); ISVNAuthenticationManager authManager =SVNWCUtil.createDefaultAuthenticationManager(userName,passwd); repositorySrc.setAuthenticationManager(authManager); repositoryTrgt.setAuthenticationManager(authManager); ISVNOptions options = SVNWCUtil.createDefaultOptions(false); // 实例化客户端管理类 ourClientManager = SVNClientManager.newInstance( (DefaultSVNOptions) options, userName, passwd); SVNCopyClient copyClient = ourClientManager.getCopyClient(); SVNCopySource[] copySources = new SVNCopySource[1]; copySources[0] = new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, repositorySrcUrl); // SVNDirEntry entry = (SVNDirEntry) srcRepository.getDir(sourceDirUrl, -1, null, (Collection) null); // if (entry.getKind() == SVNNodeKind.DIR) { // copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, false, "move", null); // } else { // copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, true, "move", null); // } copyClient.doCopy(copySources, repositoryTrgtUrl, true, false, false, "move", null); // SVNWCClient client = new SVNWCClient(authenticationManager, (ISVNOptions)(SVNWCUtil.createDefaultOptions(true))); // SVNCommitInfo svnInfo = ourClientManager.getLogClient(). // 要把此目录的内容导入到版本库 // File sourceDir = new File(sourceDirUrl); // File targetDir = new File("relative/" + targetDirUrl); // targetDir = targetDir.getAbsoluteFile(); // sourceDir.setReadable(true); // targetDir.setWritable(true); // 执行导入操作 // SVNMoveClient svnMoveClient = ourClientManager.getMoveClient(); // SVNUpdateClient svnUpdateClient = new SVNUpdateClient(authenticationManager, options); // svnMoveClient.doVirtualCopy(sourceDir, targetDir, true); // svnMoveClient.doMove(sourceDir, targetDir); // svnUpdateClient.doRelocate(sourceDir, repositorySrcUrl, repositoryTrgtUrl, true); return true; } catch (SVNException e) { // TODO: handle exception e.printStackTrace(); return false; } } }
相关文章推荐
- SVN模型仓库中的资源从一个地方移动到另一个地方的办法(很久才解决)
- VC资源视图中显示在另一个编辑器中打开时解决办法
- 移动web目录下文件提示"另一个程序正在占用"解决办法
- 移动硬盘分区变为RAW,chkdsk提示“因另一个程序正在使用这个卷,无法运行CHKDSK“ 的解决办法 .
- struts中从一个命名空间跳转到另一个命名空间的解决办法
- SVN仓库迁移到Git遇到的两个问题和解决办法
- SVN仓库迁移到Git的完美解决办法
- 打开资源视图rc文件,提示在另一个编辑器中打开,最终解决办法
- 使用 apt-get 的時候,出现目录或者被锁住的解决办法(E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源临时不可用) E: 无法对管理目录(/var/lib/dpkg/)加锁,是不是另一个包管理)
- eclipse的svn插件连接osc的代码仓库时候报错的解决办法
- 移动硬盘只能识别一个分区,另一个变为RAW的解决办法
- SVN仓库迁移到Git的完美解决办法
- win32从一个文件路径而不是资源中加载光标的解决办法
- svn 在windows下创建仓库子目录失败解决办法
- 从一个TABLE中取一行放到另一个TABLE里报错: 该行已经属于另一个表。的解决办法
- eclipse插件的svn无法更新的解决办法
- 关于ubuntu“下载软件仓库信息失败 检查您的网络连接“问题的解决办法
- win8.1系统提示print spooler错误0x800706b9资源不足的解决办法
- SVN使用笔记-cleanup解决资源锁定(locked)
- WPF 一种资源找不到的问题的解决办法