From 3b4a22a915ec7572ea90bc85aebc02aea99eed8e Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Mon, 31 Jul 2017 16:50:41 +0300 Subject: [PATCH] Fix getting svn history when repository url contains space character IDEA-176854 --- .../idea/svn/history/SvnHistoryProvider.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index f094ef7b36b2..250be409c7d6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -69,6 +69,8 @@ import java.util.Collections; import java.util.Date; import java.util.List; +import static org.jetbrains.idea.svn.SvnUtil.getRelativeUrl; + public class SvnHistoryProvider implements VcsHistoryProvider, VcsCacheableHistorySessionFactory { private final SvnVcs myVcs; @@ -334,13 +336,9 @@ public class SvnHistoryProvider @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()); - } + SVNURL repoRootURL = myInfo.getRepositoryRootURL(); + String relativeUrl = getRelativeUrl(repoRootURL.toDecodedString(), myUrl); + if (myPI != null) { myPI.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", myUrl)); } @@ -415,11 +413,7 @@ public class SvnHistoryProvider 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()); - } + String relativeUrl = getRelativeUrl(rootURL.toDecodedString(), myUrl); SvnTarget target = SvnTarget.fromURL(svnurl, myPeg == null ? myFrom : myPeg); RepositoryLogEntryHandler handler = new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, createConsumerAdapter(myConsumer), rootURL); @@ -443,13 +437,12 @@ public class SvnHistoryProvider // 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()); + if (info == null || info.getRepositoryRootURL() == null) { + throw new VcsException("Could not find repository root for URL: " + svnurl + " in revision " + myPeg); } + SVNURL rootURL = info.getRepositoryRootURL(); + String relativeUrl = getRelativeUrl(rootURL.toDecodedString(), myUrl); final RepositoryLogEntryHandler repositoryLogEntryHandler = new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, revision -> myConsumer.consume(revision), rootURL); repositoryLogEntryHandler.setThrowCancelOnMeetPathCreation(true);