@Override protected void preliminary() throws SVNException { SVNWCClient wcClient = myVcs.createWCClient(); myInfo = wcClient.doInfo(new File(myFile.getIOFile().getAbsolutePath()), SVNRevision.UNDEFINED); wcClient.setEventHandler( new ISVNEventHandler() { public void handleEvent(SVNEvent event, double progress) throws SVNException {} public void checkCancelled() throws SVNCancelException { myPI.checkCanceled(); } }); if (myInfo == null || myInfo.getRepositoryRootURL() == null) { myException = new VcsException("File ''{0}'' is not under version control" + myFile.getIOFile()); return; } if (myInfo.getURL() == null) { myException = new VcsException("File " + myFile.getPath() + " is not under Subversion control"); return; } myUrl = myInfo.getURL().toString(); }
private void collectLogEntries( final ProgressIndicator indicator, FilePath file, VcsException[] exception, final Consumer<VcsFileRevision> result, final Ref<Boolean> supports15Ref) throws SVNException, VcsException { SVNWCClient wcClient = myVcs.createWCClient(); SVNInfo info = wcClient.doInfo(new File(file.getIOFile().getAbsolutePath()), SVNRevision.UNDEFINED); wcClient.setEventHandler( new ISVNEventHandler() { public void handleEvent(SVNEvent event, double progress) throws SVNException {} public void checkCancelled() throws SVNCancelException { indicator.checkCanceled(); } }); if (info == null || info.getRepositoryRootURL() == null) { exception[0] = new VcsException("File ''{0}'' is not under version control" + file.getIOFile()); return; } final String url = info.getURL() == null ? null : info.getURL().toString(); String relativeUrl = url; final SVNURL repoRootURL = info.getRepositoryRootURL(); final String root = repoRootURL.toString(); if (url != null && url.startsWith(root)) { relativeUrl = url.substring(root.length()); } if (indicator != null) { indicator.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url)); } final SVNRevision pegRevision = info.getRevision(); SVNLogClient client = myVcs.createLogClient(); final boolean supports15 = SvnUtil.checkRepositoryVersion15(myVcs, url); supports15Ref.set(supports15); client.doLog( new File[] {new File(file.getIOFile().getAbsolutePath())}, SVNRevision.HEAD, SVNRevision.create(1), SVNRevision.UNDEFINED, false, true, supports15, 0, null, new MyLogEntryHandler( myVcs, url, pegRevision, relativeUrl, result, repoRootURL, file.getCharset())); }
@Override public SVNURL getURL() { SVNURL url = super.getURL(); if (url == null) { SVNInfo info = initInfo(); url = info != null ? info.getURL() : url; } return url; }
public String invoke(File p, VirtualChannel channel) throws IOException { final SVNClientManager manager = SubversionSCM.createSvnClientManager(authProvider); try { final SVNWCClient svnwc = manager.getWCClient(); SVNInfo info; try { info = svnwc.doInfo(p, SVNRevision.WORKING); return info.getURL().toDecodedString(); } catch (SVNException e) { e.printStackTrace(); return null; } } finally { manager.dispose(); } }
private void fillMapping(final SvnMapping mapping, final List<SvnCopyRootSimple> list) { final LocalFileSystem lfs = LocalFileSystem.getInstance(); for (SvnCopyRootSimple simple : list) { final VirtualFile copyRoot = lfs.findFileByIoFile(new File(simple.myCopyRoot)); final VirtualFile vcsRoot = lfs.findFileByIoFile(new File(simple.myVcsRoot)); if (copyRoot == null || vcsRoot == null) continue; final SvnVcs vcs = SvnVcs.getInstance(myProject); final SVNInfo svnInfo = vcs.getInfo(copyRoot); if ((svnInfo == null) || (svnInfo.getRepositoryRootURL() == null)) continue; final RootUrlInfo info = new RootUrlInfo( svnInfo.getRepositoryRootURL(), svnInfo.getURL(), SvnFormatSelector.getWorkingCopyFormat(svnInfo.getFile()), copyRoot, vcsRoot); mapping.add(info); } }
private RenameContext(final SVNInfo info) { myRepositoryRoot = info.getRepositoryRootURL().toString(); myCurrentPath = SVNPathUtil.getRelativePath(myRepositoryRoot, info.getURL().toString()); myCurrentPath = myCurrentPath.startsWith("/") ? myCurrentPath : ("/" + myCurrentPath); }
@Override public Pair<SvnChangeList, FilePath> getOneList(final VirtualFile file, VcsRevisionNumber number) throws VcsException { final RootUrlInfo rootUrlInfo = myVcs.getSvnFileUrlMapping().getWcRootForFilePath(new File(file.getPath())); if (rootUrlInfo == null) return null; final VirtualFile root = rootUrlInfo.getVirtualFile(); if (root == null) return null; final SvnRepositoryLocation svnRootLocation = (SvnRepositoryLocation) getLocationFor(new FilePathImpl(root)); if (svnRootLocation == null) return null; final String url = svnRootLocation.getURL(); final long revision; try { revision = Long.parseLong(number.asString()); } catch (NumberFormatException e) { throw new VcsException(e); } final SvnChangeList[] result = new SvnChangeList[1]; final SVNLogClient logger; final SVNRevision revisionBefore; final SVNURL repositoryUrl; final SVNURL svnurl; final SVNInfo targetInfo; try { logger = myVcs.createLogClient(); revisionBefore = SVNRevision.create(revision); svnurl = SVNURL.parseURIEncoded(url); final SVNWCClient client = myVcs.createWCClient(); final SVNInfo info = client.doInfo(svnurl, SVNRevision.UNDEFINED, SVNRevision.HEAD); targetInfo = client.doInfo(new File(file.getPath()), SVNRevision.UNDEFINED); if (info == null) { throw new VcsException("Can not get repository URL"); } repositoryUrl = info.getRepositoryRootURL(); } catch (SVNException e) { LOG.info(e); throw new VcsException(e); } tryExactHit(svnRootLocation, result, logger, revisionBefore, repositoryUrl, svnurl); if (result[0] == null) { tryByRoot(result, logger, revisionBefore, repositoryUrl); if (result[0] == null) { FilePath path = tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl); path = path == null ? new FilePathImpl(file) : path; // and pass & take rename context there return new Pair<SvnChangeList, FilePath>(result[0], path); } } if (result[0].getChanges().size() == 1) { final Collection<Change> changes = result[0].getChanges(); final Change change = changes.iterator().next(); final ContentRevision afterRevision = change.getAfterRevision(); if (afterRevision != null) { return new Pair<SvnChangeList, FilePath>(result[0], afterRevision.getFile()); } else { return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file)); } } String relativePath = SVNPathUtil.getRelativePath( targetInfo.getRepositoryRootURL().toString(), targetInfo.getURL().toString()); relativePath = relativePath.startsWith("/") ? relativePath : "/" + relativePath; final Change targetChange = result[0].getByPath(relativePath); if (targetChange == null) { FilePath path = tryStepByStep(svnRootLocation, result, logger, revisionBefore, targetInfo, svnurl); path = path == null ? new FilePathImpl(file) : path; // and pass & take rename context there return new Pair<SvnChangeList, FilePath>(result[0], path); } return new Pair<SvnChangeList, FilePath>(result[0], new FilePathImpl(file)); }