From 1c4ebddb01af4cedd216a455461b66cfb3dc9524 Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Tue, 5 Feb 2019 17:12:49 +0300 Subject: [PATCH] vcs: add registry option to process externally added files --- platform/util/resources/misc/registry.properties | 3 +++ .../vcs-impl/src/com/intellij/openapi/vcs/VcsVFSListener.java | 3 ++- .../tests/git4idea/notification/GitExternalFileNotifierTest.kt | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 813f8905c790..e21b1001ab61 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -509,6 +509,9 @@ vcs.code.analysis.before.checkin.show.only.new.threshold=-1 vcs.code.analysis.before.checkin.show.only.new.threshold.description=Show only newly introduced warnings and errors in results \ of before checkin analysis if the number of changed files is less or equals than threshold +vcs.process.externally.added.files=false +vcs.process.externally.added.files.description=Process externally added files. Add such files to VCS automatically or prompt user. + psi.incremental.reparse.depth.limit=1000 psi.deferIconLoading=true diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/VcsVFSListener.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/VcsVFSListener.java index 5110254285d2..26b749560b87 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/VcsVFSListener.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/VcsVFSListener.java @@ -11,6 +11,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.*; @@ -96,7 +97,7 @@ public abstract class VcsVFSListener implements Disposable { } private static boolean isExternalEvent(@NotNull VirtualFileEvent event) { - return event.isFromRefresh(); + return event.isFromRefresh() && Registry.is("vcs.process.externally.added.files"); } private boolean isUnderMyVcs(@NotNull VirtualFile file) { diff --git a/plugins/git4idea/tests/git4idea/notification/GitExternalFileNotifierTest.kt b/plugins/git4idea/tests/git4idea/notification/GitExternalFileNotifierTest.kt index c8422343e8ae..4d01493dfd1b 100644 --- a/plugins/git4idea/tests/git4idea/notification/GitExternalFileNotifierTest.kt +++ b/plugins/git4idea/tests/git4idea/notification/GitExternalFileNotifierTest.kt @@ -1,6 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package git4idea.notification +import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vcs.VcsBundle import com.intellij.openapi.vcs.VcsConfiguration import com.intellij.openapi.vcs.VcsShowConfirmationOption @@ -15,6 +16,7 @@ class GitExternalFileNotifierTest : GitSingleRepoTest() { override fun setUp() { super.setUp() + Registry.get("vcs.process.externally.added.files").setValue(true, testRootDisposable) setStandardConfirmation(project, vcs.name, VcsConfiguration.StandardConfirmation.ADD, VcsShowConfirmationOption.Value.SHOW_CONFIRMATION) projectRoot.children //ensure that all subsequent VFS events will be fired after new files added to projectRoot }