protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath) throws SVNException { Date date = logEntry.getDate(); String author = logEntry.getAuthor(); String message = logEntry.getMessage(); SVNRevision rev = SVNRevision.create(logEntry.getRevision()); final SVNURL url = myRepositoryRoot.appendPath(myLastPath, true); return new SvnFileRevision( myVcs, myPegRevision, rev, url.toString(), author, date, message, copyPath, myCharset); }
@Override protected SvnFileRevision createRevision( final LogEntry logEntry, final String copyPath, LogEntryPath entryPath) throws SVNException { final SVNURL url = entryPath == null ? myRepositoryRoot.appendPath(myLastPathCorrector.getBefore(), false) : myRepositoryRoot.appendPath(entryPath.getPath(), true); return new SvnFileRevision( myVcs, SVNRevision.UNDEFINED, logEntry, url.toString(), copyPath, null); }
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())); }
private void tryByRoot( SvnChangeList[] result, SVNLogClient logger, SVNRevision revisionBefore, SVNURL repositoryUrl) throws VcsException { final boolean authorized = SvnAuthenticationNotifier.passiveValidation(myProject, repositoryUrl); if (!authorized) return; tryExactHit( new SvnRepositoryLocation(repositoryUrl.toString()), result, logger, revisionBefore, repositoryUrl, repositoryUrl); }
@Nullable public static SvnBranchConfigurationNew loadDefaultConfiguration( final Project project, final VirtualFile vcsRoot) { try { final SvnVcs vcs = SvnVcs.getInstance(project); File rootFile = new File(vcsRoot.getPath()); final Info info = vcs.getInfo(rootFile); if (info == null || info.getURL() == null) { LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl()); return null; } SVNURL baseUrl = info.getURL(); final SvnBranchConfigurationNew result = new SvnBranchConfigurationNew(); result.setTrunkUrl(baseUrl.toString()); while (true) { final String s = SVNPathUtil.tail(baseUrl.getPath()); if (s.equalsIgnoreCase(DEFAULT_TRUNK_NAME) || s.equalsIgnoreCase(DEFAULT_BRANCHES_NAME) || s.equalsIgnoreCase(DEFAULT_TAGS_NAME)) { SVNURL rootPath = baseUrl.removePathTail(); SvnTarget target = SvnTarget.fromURL(rootPath); vcs.getFactory(target) .createBrowseClient() .list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath)); break; } if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) { break; } baseUrl = baseUrl.removePathTail(); } return result; } catch (SVNException e) { LOG.info(e); return null; } catch (VcsException e) { LOG.info(e); return null; } }
@Override protected void load() { String relativeUrl = myUrl; final SVNURL repoRootURL = myInfo.getRepositoryRootURL(); final String root = repoRootURL.toString(); if (myUrl != null && myUrl.startsWith(root)) { relativeUrl = myUrl.substring(root.length()); } if (myPI != null) { myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl)); } final SVNRevision pegRevision = myInfo.getRevision(); final SvnTarget target = SvnTarget.fromFile(myFile.getIOFile(), myPeg); try { myVcs .getFactory(target) .createHistoryClient() .doLog( target, myFrom == null ? SVNRevision.HEAD : myFrom, myTo == null ? SVNRevision.create(1) : myTo, false, true, myShowMergeSources && mySupport15, myLimit + 1, null, new MyLogEntryHandler( myVcs, myUrl, pegRevision, relativeUrl, createConsumerAdapter(myConsumer), repoRootURL, myFile.getCharset())); } catch (SVNCancelException e) { // } catch (SVNException e) { myException = new VcsException(e); } catch (VcsException e) { myException = e; } }
@Override public <S> List<S> filterUniqueRoots( final List<S> in, final Convertor<S, VirtualFile> convertor) { if (in.size() <= 1) return in; final List<MyPair<S>> infos = new ArrayList<MyPair<S>>(in.size()); final SvnFileUrlMappingImpl mapping = (SvnFileUrlMappingImpl) getSvnFileUrlMapping(); final List<S> notMatched = new LinkedList<S>(); for (S s : in) { final VirtualFile vf = convertor.convert(s); if (vf == null) continue; final File ioFile = new File(vf.getPath()); SVNURL url = mapping.getUrlForFile(ioFile); if (url == null) { url = SvnUtil.getUrl(this, ioFile); if (url == null) { notMatched.add(s); continue; } } infos.add(new MyPair<S>(vf, url.toString(), s)); } final List<MyPair<S>> filtered = new ArrayList<MyPair<S>>(infos.size()); ForNestedRootChecker.filterOutSuperfluousChildren(this, infos, filtered); final List<S> converted = ObjectsConvertor.convert( filtered, new Convertor<MyPair<S>, S>() { @Override public S convert(final MyPair<S> o) { return o.getSrc(); } }); if (!notMatched.isEmpty()) { // potential bug is here: order is not kept. but seems it only occurs for cases where result // is sorted after filtering so ok converted.addAll(notMatched); } return converted; }
private void loadBackwards(SVNURL svnurl) throws SVNException, VcsException { // this method is called when svnurl does not exist in latest repository revision - thus // concrete old revision is used for "info" // command to get repository url Info info = myVcs.getInfo(svnurl, myPeg, myPeg); final SVNURL rootURL = info != null ? info.getRepositoryRootURL() : null; final String root = rootURL != null ? rootURL.toString() : ""; String relativeUrl = myUrl; if (myUrl.startsWith(root)) { relativeUrl = myUrl.substring(root.length()); } final RepositoryLogEntryHandler repositoryLogEntryHandler = new RepositoryLogEntryHandler( myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, new ThrowableConsumer<VcsFileRevision, SVNException>() { @Override public void consume(VcsFileRevision revision) throws SVNException { myConsumer.consume(revision); } }, rootURL); repositoryLogEntryHandler.setThrowCancelOnMeetPathCreation(true); SvnTarget target = SvnTarget.fromURL(rootURL, myFrom); myVcs .getFactory(target) .createHistoryClient() .doLog( target, myFrom, myTo == null ? SVNRevision.create(1) : myTo, false, true, myShowMergeSources && mySupport15, 1, null, repositoryLogEntryHandler); }
@Override protected void load() { String relativeUrl = myUrl; final SVNURL repoRootURL = myInfo.getRepositoryRootURL(); final String root = repoRootURL.toString(); if (myUrl != null && myUrl.startsWith(root)) { relativeUrl = myUrl.substring(root.length()); } if (myPI != null) { myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl)); } final SVNRevision pegRevision = myInfo.getRevision(); SVNLogClient client = myVcs.createLogClient(); try { client.doLog( new File[] {new File(myFile.getIOFile().getAbsolutePath())}, SVNRevision.HEAD, SVNRevision.create(1), SVNRevision.UNDEFINED, false, true, mySupport15, 0, null, new MyLogEntryHandler( myVcs, myUrl, pegRevision, relativeUrl, myConsumer, repoRootURL, myFile.getCharset())); } catch (SVNCancelException e) { // } catch (SVNException e) { myException = new VcsException(e); } catch (VcsException e) { myException = e; } }
@Override protected void load() { if (myPI != null) { myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl)); } try { if (myForceBackwards) { SVNURL svnurl = SVNURL.parseURIEncoded(myUrl); if (!existsNow(svnurl)) { loadBackwards(svnurl); return; } } final SVNURL svnurl = SVNURL.parseURIEncoded(myUrl); SVNRevision operationalFrom = myFrom == null ? SVNRevision.HEAD : myFrom; // TODO: try to rewrite without separately retrieving repository url by item url - as this // command could require authentication // TODO: and it is not "clear enough/easy to implement" with current design (for some cases) // how to cache credentials (if in // TODO: non-interactive mode) final SVNURL rootURL = SvnUtil.getRepositoryRoot(myVcs, svnurl); if (rootURL == null) { throw new VcsException("Could not find repository root for URL: " + myUrl); } final String root = rootURL.toString(); String relativeUrl = myUrl; if (myUrl.startsWith(root)) { relativeUrl = myUrl.substring(root.length()); } SvnTarget target = SvnTarget.fromURL(svnurl, myPeg == null ? myFrom : myPeg); RepositoryLogEntryHandler handler = new RepositoryLogEntryHandler( myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, createConsumerAdapter(myConsumer), rootURL); myVcs .getFactory(target) .createHistoryClient() .doLog( target, operationalFrom, myTo == null ? SVNRevision.create(1) : myTo, false, true, myShowMergeSources && mySupport15, myLimit + 1, null, handler); } catch (SVNCancelException e) { // } catch (SVNException e) { myException = new VcsException(e); } catch (VcsException e) { myException = e; } }