From 0979631f0f5e15d386e840f98bd45e04428f0afe Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 28 Jun 2010 12:21:20 +0400 Subject: [PATCH] IDEA-22685 "File to patch found outside content root" error on unshelving changes. --- .../diff/impl/patch/formove/PathsVerifier.java | 11 ++++++++--- .../openapi/vcs/impl/ProjectLevelVcsManagerImpl.java | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PathsVerifier.java b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PathsVerifier.java index d2d57c6ac303..f5870cd2d08d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PathsVerifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/formove/PathsVerifier.java @@ -30,7 +30,7 @@ import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.changes.patch.RelativePathCalculator; import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager; -import com.intellij.openapi.vcs.impl.ExcludedFileIndex; +import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -53,6 +53,7 @@ public class PathsVerifier { private final List>> myBinaryPatches; private final List myWritableFiles; private final BaseMapper myBaseMapper; + private ProjectLevelVcsManager myVcsManager; public PathsVerifier(final Project project, final VirtualFile baseDirectory, final List patches, BaseMapper baseMapper) { myProject = project; @@ -66,6 +67,7 @@ public class PathsVerifier { myTextPatches = new ArrayList>(); myBinaryPatches = new ArrayList>>(); myWritableFiles = new ArrayList(); + myVcsManager = ProjectLevelVcsManager.getInstance(myProject); } // those to be moved to CL: target + created dirs @@ -279,13 +281,16 @@ public class PathsVerifier { protected boolean checkModificationValid(final VirtualFile file, final String name) { // security check to avoid overwriting system files with a patch - if ((file == null) || (! ExcludedFileIndex.getInstance(myProject).isInContent(file)) || - (ProjectLevelVcsManager.getInstance(myProject).getVcsRootFor(file) == null)) { + if ((file == null) || (!inContent(file)) || (myVcsManager.getVcsRootFor(file) == null)) { setErrorMessage("File to patch found outside content root: " + name); return false; } return true; } + + private boolean inContent(VirtualFile file) { + return ((ProjectLevelVcsManagerImpl) myVcsManager).isFileInContent(file); + } } private void addPatch(final FilePatch patch, final VirtualFile file) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 617b6d0a278b..e329ffc98898 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -703,7 +703,9 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes if (file == null) return false; final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { - final VirtualFile ideaDir = myProject.getBaseDir().findChild(Project.DIRECTORY_STORE_FOLDER); + final VirtualFile baseDir = myProject.getBaseDir(); + if (baseDir == null) return false; + final VirtualFile ideaDir = baseDir.findChild(Project.DIRECTORY_STORE_FOLDER); return (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory() && VfsUtil.isAncestor(ideaDir, file, false)); } return false;