IDEA-192894 vcs: use same action to refresh current VCS status
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 5 Nov 2020 17:47:46 +0000 (20:47 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 5 Nov 2020 22:03:36 +0000 (22:03 +0000)
GitOrigin-RevId: cee211b9f99584d8e527fbdc64e183e1cd8c84b8

platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesViewRefresher.java
platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/RefreshStatuses.java [deleted file]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RefreshAction.java
plugins/git4idea/resources/META-INF/plugin.xml
plugins/git4idea/src/git4idea/changes/GitChangesViewRefresher.java
plugins/git4idea/src/git4idea/index/actions/GitRefreshStageAction.kt [deleted file]
plugins/git4idea/src/git4idea/index/actions/GitStageChangesViewRefresher.kt [new file with mode: 0644]

index 15ab64a98c40905067c99fa13d9175049b11bb9b..a5ca4c2cec9cba2839d8fddbeaaa273feb44bb26 100644 (file)
@@ -1297,9 +1297,6 @@ action.IntegrateFiles.description=Integrate selected files or directories
 action.Vcs.IntegrateProject.text=Inte_grate Project
 action.Vcs.IntegrateProject.description=Integrate project
 
-action.Vcs.RefreshStatuses.text=R_efresh File Status
-action.Vcs.RefreshStatuses.description=Refresh VCS status for all files in project
-
 action.ShowNavBar.text=_Jump to Navigation Bar
 action.ShowNavBar.ShortText=Navigation Bar
 
index b0113f4a060f514240b09d803667db47244c7886..f93f5c91651c1b1539ad100760a3a333a9a8eae1 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.openapi.vcs.changes;
 
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
 
 /**
  * Implement to perform some activity when user presses "Refresh" button in the Changes View.
@@ -27,5 +28,5 @@ public interface ChangesViewRefresher {
 
   ExtensionPointName<ChangesViewRefresher> EP_NAME = ExtensionPointName.create("com.intellij.vcsChangesViewRefresher");
 
-  void refresh(Project project);
+  void refresh(@NotNull Project project);
 }
index 0e4ee43945aeeecaf7da7df0a951008c2038cff2..435b6bbe647c440a3583e981d6cd2f7e2a156f15 100644 (file)
@@ -60,6 +60,9 @@
       <add-to-group group-id="TouchBarDefaultOptionalGroup" anchor="first" />
     </group>
 
+    <action id="ChangesView.Refresh" class="com.intellij.openapi.vcs.changes.actions.RefreshAction"
+            icon="AllIcons.Actions.Refresh"/>
+
     <!-- Main menu | Version Control -->
     <group id="VcsGroups" class="com.intellij.openapi.vcs.actions.VcsGroupsActionGroup" popup="true">
       <group id="Vcs.MainMenu" class="com.intellij.openapi.vcs.actions.VcsMainMenuActionGroup">
@@ -73,7 +76,7 @@
           <reference ref="ChangesView.ToggleCommitUi"/>
           <reference ref="Vcs.UpdateProject"/>
           <action id="Vcs.IntegrateProject" class="com.intellij.openapi.vcs.update.CommonIntegrateProjectAction"/>
-          <action id="Vcs.RefreshStatuses" class="com.intellij.openapi.vcs.actions.RefreshStatuses"/>
+          <reference ref="ChangesView.Refresh"/>
           <separator/>
           <group id="Vcs.Specific" class="com.intellij.ide.actions.NonEmptyActionGroup"/>
           <separator/>
     </group>
 
     <group id="ChangesViewToolbar">
-      <action id="ChangesView.Refresh" class="com.intellij.openapi.vcs.changes.actions.RefreshAction"
-              icon="AllIcons.Actions.Refresh"/>
+      <reference ref="ChangesView.Refresh"/>
       <reference ref="CheckinProject"/>
       <reference ref="ChangesView.ToggleCommitUi"/>
       <reference ref="ChangesView.Revert"/>
       <reference ref="Vcs.QuickListPopupAction"/>
       <reference ref="Vcs.UpdateProject"/>
       <reference ref="Vcs.IntegrateProject"/>
-      <reference ref="Vcs.RefreshStatuses"/>
       <separator/>
       <reference ref="ChangesView.Browse"/>
       <reference ref="ChangesView.CreatePatch"/>
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/RefreshStatuses.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/RefreshStatuses.java
deleted file mode 100644 (file)
index 79e7027..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2000-2019 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 com.intellij.openapi.vcs.actions;
-
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.ProjectLevelVcsManager;
-import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
-import org.jetbrains.annotations.NotNull;
-
-public class RefreshStatuses extends AnAction implements DumbAware {
-  @Override
-  public void actionPerformed(@NotNull AnActionEvent e) {
-    Project project = e.getProject();
-    if (project != null) {
-      VcsDirtyScopeManager.getInstance(project).markEverythingDirty();
-    }
-  }
-
-  @Override
-  public void update(@NotNull AnActionEvent e) {
-    final Project project = e.getProject();
-    boolean isEnabled = project != null &&
-        ProjectLevelVcsManager.getInstance(project).getAllActiveVcss().length > 0;
-    e.getPresentation().setEnabledAndVisible(isEnabled);
-  }
-}
index 5c69c1a2cc57767d6c430bcbfee672e89229a94c..9a8330c28735705322f819f0a100e8336b892d85 100644 (file)
@@ -9,6 +9,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.FilePath;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
 import com.intellij.openapi.vcs.VcsBundle;
 import com.intellij.openapi.vcs.changes.*;
 import com.intellij.openapi.vfs.VirtualFileManager;
@@ -22,6 +23,13 @@ import static com.intellij.openapi.vcs.changes.actions.VcsActionUsagesCollectorK
  * @author yole
  */
 public class RefreshAction extends AnAction implements DumbAware {
+  @Override
+  public void update(@NotNull AnActionEvent e) {
+    Project project = e.getProject();
+    boolean isEnabled = project != null && ProjectLevelVcsManager.getInstance(project).hasActiveVcss();
+    e.getPresentation().setEnabledAndVisible(isEnabled);
+  }
+
   @Override
   public void actionPerformed(@NotNull AnActionEvent e) {
     final Project project = e.getData(CommonDataKeys.PROJECT);
index ea1a3bb6b50fb86c9fb23db0c948adb99134f138..86701e5bd834c58e202d99660b9acb392f6db5a0 100644 (file)
     </action>
 
     <action id="Git.Show.Stage" class="git4idea.index.actions.GitShowStagingAreaAction" use-shortcut-of="CheckinProject"/>
-    <action id="Git.Stage.Refresh" class="git4idea.index.actions.GitRefreshStageAction" icon="AllIcons.Actions.Refresh"
-            use-shortcut-of="Refresh"/>
     <action id="Git.Stage.Add" class="git4idea.index.actions.GitAddAction" use-shortcut-of="ChangesView.AddUnversioned"/>
     <action id="Git.Stage.Reset" class="git4idea.index.actions.GitResetAction" use-shortcut-of="ChangesView.Revert"/>
     <action id="Git.Stage.Revert" class="git4idea.index.actions.GitRevertAction" use-shortcut-of="ChangesView.Revert"/>
 
     <group id="Git.Stage.Toolbar">
       <reference id="Diff.ShowDiff"/>
-      <reference id="Git.Stage.Refresh"/>
+      <reference id="ChangesView.Refresh"/>
       <reference id="Git.Stash.Silently"/>
       <group id="Git.Stage.Ui.Settings" icon="AllIcons.Actions.Show" popup="true">
         <reference id="Git.Stage.ToggleIgnored"/>
 
     <projectService serviceImplementation="git4idea.index.GitStageTracker"/>
     <openapi.vcs.impl.LocalLineStatusTrackerProvider implementation="git4idea.index.GitStageLineStatusTrackerProvider"/>
+    <vcsChangesViewRefresher implementation="git4idea.index.actions.GitStageChangesViewRefresher"/>
 
     <backgroundPostStartupActivity implementation="git4idea.index.GitStageManager$GitStageStartupActivity"/>
 
index 8517c2a3e5928a1932aeb6d47cc9562ea01411ee..c70ac3e5872e3d3e002f1ff4833e53fc9aef5e69 100644 (file)
@@ -22,18 +22,16 @@ import git4idea.repo.GitRepositoryManager;
 import org.jetbrains.annotations.NotNull;
 
 /**
- * Untracked files in Git are not queried within the normal refresh procedure - they are watched separately.
+ * Untracked and ignored files in Git are not queried within the normal refresh procedure - they are watched separately.
  * I.e. to make a full refresh when user presses "Refresh" in the Changes View it is needed to prepare untracked files for refresh as well.
- *
- * @author Kirill Likhodedov
  */
 public class GitChangesViewRefresher implements ChangesViewRefresher {
-
   @Override
   public void refresh(@NotNull Project project) {
     GitRepositoryManager repositoryManager = GitRepositoryManager.getInstance(project);
     for (GitRepository repository : repositoryManager.getRepositories()) {
       repository.getUntrackedFilesHolder().invalidate();
+      repository.getIgnoredFilesHolder().startRescan();
     }
   }
 }
diff --git a/plugins/git4idea/src/git4idea/index/actions/GitRefreshStageAction.kt b/plugins/git4idea/src/git4idea/index/actions/GitRefreshStageAction.kt
deleted file mode 100644 (file)
index 1f2969f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2000-2020 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.index.actions
-
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.project.DumbAwareAction
-import com.intellij.openapi.vcs.VcsBundle
-import git4idea.index.ui.GitStageDataKeys
-import git4idea.index.vfs.GitIndexFileSystemRefresher
-
-class GitRefreshStageAction : DumbAwareAction(VcsBundle.messagePointer("action.name.refresh")) {
-
-  override fun update(e: AnActionEvent) {
-    e.presentation.isEnabledAndVisible = e.getData(GitStageDataKeys.GIT_STAGE_TRACKER) != null && e.project != null
-  }
-
-  override fun actionPerformed(e: AnActionEvent) {
-    e.getRequiredData(GitStageDataKeys.GIT_STAGE_TRACKER).scheduleUpdateAll()
-    GitIndexFileSystemRefresher.getInstance(e.project!!).refresh { true }
-  }
-}
\ No newline at end of file
diff --git a/plugins/git4idea/src/git4idea/index/actions/GitStageChangesViewRefresher.kt b/plugins/git4idea/src/git4idea/index/actions/GitStageChangesViewRefresher.kt
new file mode 100644 (file)
index 0000000..e023d61
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2000-2020 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.index.actions
+
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.vcs.changes.ChangesViewRefresher
+import git4idea.index.vfs.GitIndexFileSystemRefresher
+
+class GitStageChangesViewRefresher : ChangesViewRefresher {
+  override fun refresh(project: Project) {
+    GitIndexFileSystemRefresher.getInstance(project).refresh { true }
+  }
+}