public SvnLogFileInfo getLastFileRevision(SvnLogFileInfo fInfo) { SvnLogFileInfo fileInfo = null; List<SVNFileRevision> s = new ArrayList<SVNFileRevision>(); int index = -2; try { this.repository.getFileRevisions(fInfo.getFilename(), s, 0, fInfo.getRevision()); } catch (SVNException e) { logger.error(e.getMessage()); }
index = s.size() + index;
if (index >= 0) { SVNFileRevision revision = s.get(index); fileInfo = new SvnLogFileInfo(); fileInfo.setFilename(revision.getPath(),this.getRepositoryType()); fileInfo.setRevision(revision.getRevision()); }
return fileInfo; }
public boolean copyFile(String workspace, String type, SvnLogFileInfo fileInfo) {
FileOutputStream fo = null; boolean isSuccess = false; try { SVNProperties pro = new SVNProperties(); File file = new File(workspace + "\\" + type + "\\" + fileInfo.getShortFileName()); fo = new FileOutputStream(file); try { this.repository.getFile(fileInfo.getFilename(), fileInfo.getRevision(), pro, fo); } catch (SVNException e) { logger.error("query the file "+fileInfo.getShortFileName()+"'info from repository, but file copy failed!"); } fo.close(); isSuccess = true; } catch (Exception e) { logger.error(e.getMessage()); } finally { try { if (fo != null) { fo.close(); } } catch (IOException e) { logger.error(e.getMessage()); } } return isSuccess; }
public long getLatestRevision() { long lastRevision = 0; try { lastRevision = this.repository.getLatestRevision(); } catch (SVNException e) { logger.error("Lastest revision of this repository is not exists!"); } return lastRevision; }
public String getSvnRoot() { SVNURL url = null; try { url = this.repository.getRepositoryRoot(false); return url.getPath(); } catch (SVNException e) { e.printStackTrace(); logger.error("You have no right get this repository root url !!!"); } return null; }
public String[] getCodePaths(String url) { String codepath = getSvnRoot(); int homeIndex = url.indexOf(codepath); return new String[] { url.substring(homeIndex + codepath.length()) }; }