From 894669b3ca684de2e751fbc20217fbbe53d2a5f3 Mon Sep 17 00:00:00 2001 From: Irina Chernushina Date: Fri, 24 Apr 2009 13:44:28 +0400 Subject: [PATCH] VCS: see local changes under '.idea' for directory-based project --- .../vcs/impl/ModuleDefaultVcsRootPolicy.java | 33 ++++++++++++++++++++-- .../components/impl/stores/IProjectStore.java | 4 +++ .../components/impl/stores/ProjectStoreImpl.java | 5 ++++ .../src/com/intellij/mock/MockProjectStore.java | 6 ++++ .../openapi/vcs/ex/ProjectLevelVcsManagerEx.java | 2 ++ .../vcs/impl/ProjectLevelVcsManagerImpl.java | 4 +++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java index e004c35260..bf90958737 100644 --- a/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java +++ b/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java @@ -5,16 +5,21 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.DirtBuilder; +import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.components.StorageScheme; +import com.intellij.util.PathUtil; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.io.File; /** * @author yole @@ -34,6 +39,13 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { if (myBaseDir != null && vcs.getName().equals(mappingList.getVcsFor(myBaseDir)) && vcs.fileIsUnderVcs(new FilePathImpl(myBaseDir))) { result.add(myBaseDir); } + final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); + if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER); + if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) { + result.add(ideaDir); + } + } // assertion for read access inside final Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable() { public Module[] compute() { @@ -78,11 +90,27 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { if (contentRoot != null) { return contentRoot; } + final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); + if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + final VirtualFile ideaDir = myBaseDir.findChild(Project.DIRECTORY_STORE_FOLDER); + if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) { + if (VfsUtil.isAncestor(ideaDir, file, false)) { + return ideaDir; + } + } + } return null; } public void markDefaultRootsDirty(final DirtBuilder builder) { + final VirtualFile baseDir = myProject.getBaseDir(); + final Module[] modules = myModuleManager.getModules(); + final StorageScheme storageScheme = ((ProjectEx) myProject).getStateStore().getStorageScheme(); + if (StorageScheme.DIRECTORY_BASED.equals(storageScheme)) { + builder.addDirtyDirRecursively(new FilePathImpl(new File(PathUtil.toPresentableUrl(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER), true)); + } + for(Module module: modules) { final VirtualFile[] files = ModuleRootManager.getInstanceChecked(module).getContentRoots(); for(VirtualFile file: files) { @@ -90,12 +118,13 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { } } - final VirtualFile baseDir = myProject.getBaseDir(); final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(myProject); + final boolean haveDefaultMapping = ((ProjectLevelVcsManagerEx)plVcsManager).haveDefaultMapping(); + final VcsRoot[] vcsRoots = plVcsManager.getAllVcsRoots(); for (VcsRoot root : vcsRoots) { - if (root.path.equals(baseDir)) { + if (haveDefaultMapping && root.path.equals(baseDir)) { builder.addDirtyFile(root); } else { diff --git a/platform-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java b/platform-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java index 024fdd236c..23f540ab03 100644 --- a/platform-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java +++ b/platform-impl/src/com/intellij/openapi/components/impl/stores/IProjectStore.java @@ -1,6 +1,7 @@ package com.intellij.openapi.components.impl.stores; import com.intellij.openapi.components.StateStorage; +import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.project.impl.ProjectImpl; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.Pair; @@ -35,6 +36,9 @@ public interface IProjectStore extends IComponentStore { @NotNull String getProjectName(); + @NotNull + StorageScheme getStorageScheme(); + @Nullable String getPresentableUrl(); diff --git a/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 1ed6e58f03..c0b243859e 100644 --- a/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -279,6 +279,11 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject return temp; } + @NotNull + public StorageScheme getStorageScheme() { + return myScheme; + } + @Nullable public String getPresentableUrl() { if (myProject.isDefault()) return null; diff --git a/testFramework/src/com/intellij/mock/MockProjectStore.java b/testFramework/src/com/intellij/mock/MockProjectStore.java index 530d9f3efb..d28e33a0c7 100644 --- a/testFramework/src/com/intellij/mock/MockProjectStore.java +++ b/testFramework/src/com/intellij/mock/MockProjectStore.java @@ -4,6 +4,7 @@ package com.intellij.mock; import com.intellij.openapi.components.StateStorage; +import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.components.impl.stores.StateStorageManager; import com.intellij.openapi.project.impl.ProjectImpl; @@ -59,6 +60,11 @@ public class MockProjectStore implements IProjectStore { throw new UnsupportedOperationException("Method getProjectName not implemented in " + getClass()); } + @NotNull + public StorageScheme getStorageScheme() { + throw new UnsupportedOperationException("Method getStorageScheme is not yet implemented in " + getClass().getName()); + } + public void loadProject() throws IOException, JDOMException, InvalidDataException { throw new UnsupportedOperationException("Method loadProject is not yet implemented in " + getClass().getName()); } diff --git a/vcs-impl/src/com/intellij/openapi/vcs/ex/ProjectLevelVcsManagerEx.java b/vcs-impl/src/com/intellij/openapi/vcs/ex/ProjectLevelVcsManagerEx.java index 1387ebec49..12e48b8916 100644 --- a/vcs-impl/src/com/intellij/openapi/vcs/ex/ProjectLevelVcsManagerEx.java +++ b/vcs-impl/src/com/intellij/openapi/vcs/ex/ProjectLevelVcsManagerEx.java @@ -44,4 +44,6 @@ public abstract class ProjectLevelVcsManagerEx extends ProjectLevelVcsManager { public abstract UpdateInfoTree showUpdateProjectInfo(UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo); public abstract void fireDirectoryMappingsChanged(); + + public abstract boolean haveDefaultMapping(); } \ No newline at end of file diff --git a/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 44948ba8bf..c417f64fc2 100644 --- a/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -848,4 +848,8 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme myProject.getMessageBus().syncPublisher(VCS_MAPPING_CHANGED).run(); } } + + public boolean haveDefaultMapping() { + return myDirectoryMappingList.haveDefaultMapping(); + } } -- 2.11.4.GIT