[git] fix deep comparator keeping highlighting after branch filter unset idea/171.965
authorJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Mon, 14 Nov 2016 21:29:26 +0000 (00:29 +0300)
committerJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Mon, 14 Nov 2016 21:31:16 +0000 (00:31 +0300)
When branch filter is unset, cherri-picked commits should be un-highlighted. But when this happen during refresh, visible pack arrives with both new graph and new filters. So DeepComparator should check filters first.

plugins/git4idea/src/git4idea/branch/DeepComparator.java

index 7aed03546ce8a0eb12cb4b7faee6912624bd53d3..4cd1d3bc768904b410d0985b2917f86d69c88f2e 100644 (file)
@@ -139,9 +139,14 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
       return;
     }
 
+    String comparedBranch = myTask.myComparedBranch;
+    VcsLogBranchFilter branchFilter = dataPack.getFilters().getBranchFilter();
+    if (branchFilter == null || !myTask.myComparedBranch.equals(VcsLogUtil.getSingleFilteredBranch(branchFilter, dataPack.getRefs()))) {
+      stopAndUnhighlight();
+      return;
+    }
+
     if (refreshHappened) {
-      // collect data
-      String comparedBranch = myTask.myComparedBranch;
       Map<GitRepository, GitBranch> repositoriesWithCurrentBranches = myTask.myRepositoriesWithCurrentBranches;
       VcsLogDataProvider provider = myTask.myProvider;
 
@@ -149,14 +154,12 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
 
       // highlight again
       Map<GitRepository, GitBranch> repositories = getRepositories(dataPack.getLogProviders(), comparedBranch);
-      if (repositories.equals(repositoriesWithCurrentBranches)) { // but not if current branch changed
+      if (repositories.equals(repositoriesWithCurrentBranches)) {
+        // but not if current branch changed
         highlightInBackground(comparedBranch, provider);
       }
-    }
-    else {
-      VcsLogBranchFilter branchFilter = dataPack.getFilters().getBranchFilter();
-      if (branchFilter == null || !myTask.myComparedBranch.equals(VcsLogUtil.getSingleFilteredBranch(branchFilter, dataPack.getRefs()))) {
-        stopAndUnhighlight();
+      else {
+        removeHighlighting();
       }
     }
   }
@@ -278,6 +281,5 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
       handler.runInCurrentThread(null);
       return pickedCommits;
     }
-
   }
 }
\ No newline at end of file