获取Svn mergeInfo总结
方法一:
利用svnkit的api进行获取,代码如下:
public String getMergeInfo1(String svnURL) { Properties properties = System.getProperties(); properties.setProperty("svnkit.http.methods", "Basic,Digest,NTLM"); SVNRepository repository = null; try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(svnURL)); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("username", "password"); repository.setAuthenticationManager(authManager); long latestRevision = repository.getLatestRevision(); Map<String, SVNMergeInfo> mergeInfo = repository.getMergeInfo(new String[] { "" }, latestRevision, SVNMergeInfoInheritance.EXPLICIT, false); return mergeInfo.toString(); } catch (SVNException e) { e.printStackTrace(); } return ""; }
public String getMergeInfo2(String svnURL) { StringBuilder sb = new StringBuilder(); Process exec = null; BufferedReader br = null; try { exec = Runtime.getRuntime().exec("svn pg svn:mergeinfo " + svnURL); InputStream inputStream = exec.getInputStream(); br = new BufferedReader(new InputStreamReader(inputStream)); String str = null; while ((str = br.readLine()) != null) { sb.append(str); sb.append("\r\n"); } } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return sb.toString(); }