mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Subversion: correctly determine local path by URL (fix SvnCommittedViewTest)
This commit is contained in:
+11
-1
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.SvnRevisionNumber;
|
||||
import org.jetbrains.idea.svn.SvnUtil;
|
||||
import org.jetbrains.idea.svn.SvnVcs;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||
@@ -65,7 +66,16 @@ public class SvnRepositoryContentRevision implements ContentRevision, MarkerVcsC
|
||||
myFilePath = localPath;
|
||||
}
|
||||
else {
|
||||
myFilePath = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(myPath, false);
|
||||
FilePath local;
|
||||
try {
|
||||
final String fullPath = SvnUtil.appendMultiParts(repositoryRoot, myPath);
|
||||
local = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(fullPath, false);
|
||||
}
|
||||
catch (SVNException e) {
|
||||
// todo what to do safely?
|
||||
local = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(repositoryRoot, false);
|
||||
}
|
||||
myFilePath = local;
|
||||
}
|
||||
myRevision = revision;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,18 @@
|
||||
package org.jetbrains.idea.svn.history;
|
||||
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.RootUrlInfo;
|
||||
import org.jetbrains.idea.svn.SvnUtil;
|
||||
import org.jetbrains.idea.svn.SvnVcs;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
import org.tmatesoft.svn.core.internal.util.SVNURLUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -62,9 +68,26 @@ public class SvnRepositoryLocation implements RepositoryLocation {
|
||||
@Nullable
|
||||
public static FilePath getLocalPath(final String fullPath, final NotNullFunction<File, Boolean> detector, final SvnVcs vcs) {
|
||||
if (vcs.getProject().isDefault()) return null;
|
||||
final SVNURL fullPathURL;
|
||||
try {
|
||||
fullPathURL = SVNURL.parseURIEncoded(fullPath);
|
||||
}
|
||||
catch (SVNException e) {
|
||||
return null;
|
||||
}
|
||||
final RootUrlInfo rootForUrl = vcs.getSvnFileUrlMapping().getWcRootForUrl(fullPath);
|
||||
if (rootForUrl != null) {
|
||||
return LocationDetector.filePathByUrlAndPath(fullPath, rootForUrl.getUrl().toString(), rootForUrl.getIoFile().getAbsolutePath(), detector);
|
||||
} else {
|
||||
final VirtualFile[] underVcs = ProjectLevelVcsManager.getInstance(vcs.getProject()).getRootsUnderVcs(vcs);
|
||||
if (underVcs.length == 0) return null;
|
||||
for (VirtualFile vf : underVcs) {
|
||||
final File ioFile = new File(vf.getPath());
|
||||
final SVNURL url = SvnUtil.getUrl(vcs, ioFile);
|
||||
if (url != null && SVNURLUtil.isAncestor(url, fullPathURL)) {
|
||||
return LocationDetector.filePathByUrlAndPath(fullPath, url.toString(), ioFile.getPath(), detector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user