用 CMD 脚本获得当前 svn 目录下各文件及目录的最大 revision 号

此文版权属于作者智勇,任何人、媒体或者网站转载、借用都必须征得作者本人同意

 



@echo   off
rem  版权所有 智勇

set   / a REVISION_NUMBER = 1
set  OWNER_NAME = ?

for   / " tokens=1,6,7 delims=  "  %%i in  ( 'svn . exe list -v' )   do   (
    
call   :SETNUM  %%i %%j %%k
)

echo .
echo  max revision number : %REVISION_NUMBER%% ,  owner : %OWNER_NAME%

set  REVISION_NUMBER =
set  OWNER_NAME =

echo .
pause

goto   :eof

:SETNUM
    
if   %1  GTR %REVISION_NUMBER%  (
        
set   / a REVISION_NUMBER = %1
        
if  [ %3 ] == []  ( set  OWNER_NAME = %2 )   else   ( set  OWNER_NAME = %3 )
    
)
    
goto   :eof


在Java中获取SVN目录下的文件是可以通过使用SVNKit库来实现的。SVNKit是一个开源的Java库,用于访问和操作Subversion(SVN)版本控制系统。 首先,你需要通过Maven或手动下载SVNKit库,并将其添加到你的Java项目中。 接下来,你可以使用以下代码来获取SVN目录下的文件: ```java import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.auth.*; import org.tmatesoft.svn.core.internal.io.dav.*; import org.tmatesoft.svn.core.internal.io.svn.*; import org.tmatesoft.svn.core.io.*; import org.tmatesoft.svn.core.wc.*; public class SVNFileFetcher { public static void main(String[] args) { String url = "svn://your-svn-repository-url"; String username = "your-username"; String password = "your-password"; String filePath = "/path/to/svn-file"; SVNRepository repository = null; try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password); repository.setAuthenticationManager(authManager); SVNNodeKind nodeKind = repository.checkPath(filePath, -1); if (nodeKind == SVNNodeKind.FILE) { SVNProperties fileProperties = new SVNProperties(); repository.getFile(filePath, -1, fileProperties, null); // 进一步处理文件内容 System.out.println("文件内容:"); System.out.println(fileProperties.getStringValue("svn:mime-type")); System.out.println(new String(fileProperties.getStringValue(SVNProperty.WC_TEXT_TIME).getBytes("UTF-8"))); } else { System.out.println("该路径不是文件"); } } catch (SVNException e) { e.printStackTrace(); } finally { if (repository != null) { repository.closeSession(); } } } } ``` 在上面的代码中,你需要将`url`、`username`、`password`、`filePath`替换为你的SVN仓库的信息和文件路径。使用SVNRepository创建一个与SVN仓库的连接,并使用ISVNAuthenticationManager来设置身份验证,然后通过调用repository.checkPath来检查文件是否存在。如果文件存在,可以通过调用`repository.getFile`方法获取文件的内容,进一步对文件进行处理。 需要注意的是,在使用SVNKit连接到SVN仓库之前,你需要确保已经正确设置了SVN服务器的信息以及正确配置了认证管理器。 希望这个答案能对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值