diff --git a/platform/icons/src/vcs/mapBase.png b/platform/icons/src/vcs/mapBase.png new file mode 100644 index 000000000000..043c3501e4bb Binary files /dev/null and b/platform/icons/src/vcs/mapBase.png differ diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/TestsLocationProviderUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/TestsLocationProviderUtil.java index ecaf0ae2dcfd..0d387f6b543b 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/TestsLocationProviderUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/TestsLocationProviderUtil.java @@ -91,17 +91,29 @@ public class TestsLocationProviderUtil { fileName = pathComponent; } } + if (fileName == null) { + return Collections.emptyList(); + } + return findFilesClosestToTarget(folders, collectCandidates(project, fileName)); + } - //otherwise let's find all files with the same name and similar relative path - final List filesInfo = collectCandidates(project, fileName); + /** + * Looks for files with given name which are close to given path + * @param targetParentFolders folders path + * @param candidates + * @return + */ + public static List findFilesClosestToTarget(@NotNull final List targetParentFolders, + final List candidates) { + // let's find all files with similar relative path - if (filesInfo.isEmpty()) { + if (candidates.isEmpty()) { return Collections.emptyList(); } // let's iterate relative path components and determine which files are closer to our relative path - for (String folderName : folders) { - for (FileInfo info : filesInfo) { + for (String folderName : targetParentFolders) { + for (FileInfo info : candidates) { info.processRelativePathComponent(folderName); } } @@ -110,7 +122,7 @@ public class TestsLocationProviderUtil { // we also assume that relative files and folders should have at least one common parent folder - just // to remove false positives on some cases int maxProximity = 0; - for (FileInfo fileInfo : filesInfo) { + for (FileInfo fileInfo : candidates) { final int proximity = fileInfo.getProximity(); if (proximity > maxProximity) { maxProximity = proximity; @@ -119,7 +131,7 @@ public class TestsLocationProviderUtil { if (maxProximity >= MIN_PROXIMITY_TRESHOLD) { final List files = new ArrayList(); - for (FileInfo info : filesInfo) { + for (FileInfo info : candidates) { if (info.getProximity() == maxProximity) { files.add(info.getFile()); } @@ -130,14 +142,7 @@ public class TestsLocationProviderUtil { return Collections.emptyList(); } - //private static int compare(final FileInfo info1, final FileInfo info2) { - // final int proximity1 = info1.getProximity(); - // final int proximity2 = info2.getProximity(); - // - // return proximity2 - proximity1; - //} - - private static List collectCandidates(Project project, String fileName) { + public static List collectCandidates(Project project, String fileName) { final List filesInfo = new ArrayList(); final ChooseByNameContributor[] contributors = Extensions.getExtensions(ChooseByNameContributor.FILE_EP_NAME); for (ChooseByNameContributor contributor : contributors) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java index 73397442fa3e..f5d62e253c04 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListWorker.java @@ -371,7 +371,7 @@ public class ChangeListWorker implements ChangeListsWriteOperations { for (String name : myListsToDisappear) { final LocalChangeList changeList = myMap.get(name); - if (changeList.getChanges().isEmpty()) { + if (changeList.getChanges().isEmpty() && (! changeList.isReadOnly()) && (! changeList.isDefault())) { removeChangeList(name); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java index 17b24125690a..259933e1dbdc 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java @@ -529,7 +529,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper { private final NewBaseSelector myNewBaseSelector; private MapDirectory() { - super("Map base directory", "Map base directory", IconLoader.getIcon("/actions/browser-externalJavaDoc.png")); + super("Map base directory", "Map base directory", IconLoader.getIcon("/vcs/mapBase.png")); myNewBaseSelector = new NewBaseSelector(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java index d3fe41551af1..c39b4b29dfed 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java @@ -24,16 +24,14 @@ import com.intellij.openapi.vcs.annotate.AnnotationProvider; import com.intellij.openapi.vcs.annotate.FileAnnotation; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.SvnVcs; -import org.jetbrains.idea.svn.SvnConfiguration; -import org.jetbrains.idea.svn.SvnUtil; +import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.history.SvnFileRevision; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.*; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.IOException; import java.util.Date; public class SvnAnnotationProvider implements AnnotationProvider { @@ -44,15 +42,19 @@ public class SvnAnnotationProvider implements AnnotationProvider { } public FileAnnotation annotate(final VirtualFile file) throws VcsException { - return annotate(file, new SvnFileRevision(myVcs, SVNRevision.WORKING, SVNRevision.WORKING, null, null, null, null, null)); + return annotate(file, new SvnFileRevision(myVcs, SVNRevision.WORKING, SVNRevision.WORKING, null, null, null, null, null), true); } public FileAnnotation annotate(final VirtualFile file, final VcsFileRevision revision) throws VcsException { + return annotate(file, revision, false); + } + + private FileAnnotation annotate(final VirtualFile file, final VcsFileRevision revision, final boolean loadExternally) throws VcsException { if (file.isDirectory()) { throw new VcsException(SvnBundle.message("exception.text.cannot.annotate.directory")); } final FileAnnotation[] annotation = new FileAnnotation[1]; - final SVNException[] exception = new SVNException[1]; + final VcsException[] exception = new VcsException[1]; Runnable command = new Runnable() { public void run() { @@ -60,16 +62,22 @@ public class SvnAnnotationProvider implements AnnotationProvider { try { final File ioFile = new File(file.getPath()).getAbsoluteFile(); - final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - myVcs.createWCClient().doGetFileContents(ioFile, SVNRevision.UNDEFINED, SVNRevision.BASE, true, buffer); - final String contents = LoadTextUtil.getTextByBinaryPresentation(buffer.toByteArray(), file, false).toString(); + final String contents; + if (loadExternally) { + final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + myVcs.createWCClient().doGetFileContents(ioFile, SVNRevision.UNDEFINED, SVNRevision.BASE, true, buffer); + contents = LoadTextUtil.getTextByBinaryPresentation(buffer.toByteArray(), file, false).toString(); + } else { + revision.loadContent(); + contents = LoadTextUtil.getTextByBinaryPresentation(revision.getContent(), file, false).toString(); + } final SvnFileAnnotation result = new SvnFileAnnotation(myVcs, file, contents); SVNWCClient wcClient = myVcs.createWCClient(); SVNInfo info = wcClient.doInfo(ioFile, SVNRevision.WORKING); if (info == null) { - exception[0] = new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile)); + exception[0] = new VcsException(new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile))); return; } final String url = info.getURL() == null ? null : info.getURL().toString(); @@ -129,7 +137,8 @@ public class SvnAnnotationProvider implements AnnotationProvider { }; final boolean supportsMergeinfo = SvnUtil.checkRepositoryVersion15(myVcs, url); - client.doAnnotate(ioFile, SVNRevision.UNDEFINED, SVNRevision.create(0), endRevision, true, supportsMergeinfo, annotateHandler, null); + final SVNRevision svnRevision = ((SvnRevisionNumber)revision.getRevisionNumber()).getRevision(); + client.doAnnotate(ioFile, svnRevision, SVNRevision.create(0), endRevision, true, supportsMergeinfo, annotateHandler, null); client.doLog(new File[]{ioFile}, endRevision, SVNRevision.create(1), SVNRevision.UNDEFINED, false, false, supportsMergeinfo, 0, null, new ISVNLogEntryHandler() { @@ -145,6 +154,10 @@ public class SvnAnnotationProvider implements AnnotationProvider { annotation[0] = result; } catch (SVNException e) { + exception[0] = new VcsException(e); + } catch (IOException e) { + exception[0] = new VcsException(e); + } catch (VcsException e) { exception[0] = e; } }