关于账户登录验证参考上一篇文章。
/**
* 更新svn代码
* @param clientManager 客户端管理器
* @param wcPath
* 本地文件或文件夹路径
* @param updateToRevision
* 更新到的版本 一般是SVNRevision.HEAD 最新版本
* @param depth
* 更新的深度:目录、子目录、文件
* @return
* @throws Exception
*/
public static long doUpdateCode(SVNClientManager clientManager, File wcPath,
SVNRevision updateToRevision, SVNDepth depth) throws Exception {
SVNUpdateClient updateClient = clientManager.getUpdateClient();
/*
* sets externals not to be ignored during the update
*/
updateClient.setIgnoreExternals(false);
// 如果 version = -1 视为失败
long version = 0;
try {
version = updateClient.doUpdate(wcPath, updateToRevision, depth, false, false);
} catch (SVNException e) {
e.printStackTrace();
throw new Exception("执行doUpdateCode失败:" + e.getMessage());
}
return version;
}