diff --git a/platform/dvcs-impl/src/META-INF/dvcs.xml b/platform/dvcs-impl/src/META-INF/dvcs.xml
index 76082ec380b0..c045e58a9e3a 100644
--- a/platform/dvcs-impl/src/META-INF/dvcs.xml
+++ b/platform/dvcs-impl/src/META-INF/dvcs.xml
@@ -38,7 +38,6 @@
-
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
index 94c2049fb11a..53c3d9527d45 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogProvider.java
@@ -106,6 +106,15 @@ public interface VcsLogProvider {
@Nullable
T getPropertyValue(VcsLogProperties.VcsLogProperty property);
+ /**
+ * Returns currently checked out branch in given root, or null if not on any branch or provided root is not under version control.
+ *
+ * @param root root for which branch is requested.
+ * @return branch that is currently checked out in the specified root.
+ */
+ @Nullable
+ String getCurrentBranch(@NotNull VirtualFile root);
+
interface Requirements {
/**
diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
index bc5c43eb924d..88829f0f3b0c 100644
--- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml
+++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
@@ -17,6 +17,7 @@
+
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/CurrentBranchHighlighter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/CurrentBranchHighlighter.java
similarity index 64%
rename from platform/dvcs-impl/src/com/intellij/dvcs/ui/CurrentBranchHighlighter.java
rename to platform/vcs-log/impl/src/com/intellij/vcs/log/ui/CurrentBranchHighlighter.java
index ac2b4dc0ca7d..effd6e1bcaeb 100644
--- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/CurrentBranchHighlighter.java
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/CurrentBranchHighlighter.java
@@ -13,20 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.dvcs.ui;
+package com.intellij.vcs.log.ui;
-import com.intellij.dvcs.repo.Repository;
-import com.intellij.dvcs.repo.VcsRepositoryManager;
import com.intellij.openapi.util.Condition;
import com.intellij.ui.JBColor;
-import com.intellij.vcs.log.Hash;
-import com.intellij.vcs.log.VcsCommitStyleFactory;
-import com.intellij.vcs.log.VcsLogHighlighter;
-import com.intellij.vcs.log.VcsShortCommitDetails;
+import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.LoadingDetails;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.data.VcsLogUiProperties;
-import com.intellij.vcs.log.ui.VcsLogHighlighterFactory;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -35,12 +29,10 @@ public class CurrentBranchHighlighter implements VcsLogHighlighter {
private static final JBColor CURRENT_BRANCH_BG = new JBColor(new Color(228, 250, 255), new Color(63, 71, 73));
@NotNull private final VcsLogUiProperties myUiProperties;
@NotNull private final VcsLogDataHolder myDataHolder;
- @NotNull private final VcsRepositoryManager myRepositoryManager;
public CurrentBranchHighlighter(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUiProperties uiProperties) {
myDataHolder = logDataHolder;
myUiProperties = uiProperties;
- myRepositoryManager = myDataHolder.getProject().getComponent(VcsRepositoryManager.class);
}
@NotNull
@@ -49,17 +41,12 @@ public class CurrentBranchHighlighter implements VcsLogHighlighter {
if (isSelected || !myUiProperties.isHighlightCurrentBranch()) return VcsCommitStyle.DEFAULT;
VcsShortCommitDetails details = myDataHolder.getMiniDetailsGetter().getCommitDataIfAvailable(commitIndex);
if (details != null && !(details instanceof LoadingDetails)) {
- Repository repo = myRepositoryManager.getRepositoryForRoot(details.getRoot());
- if (repo != null) {
- String currentBranch = repo.getCurrentBranchName();
- if (currentBranch == null) {
- if (repo.getCurrentRevision() != null) currentBranch = "HEAD"; // does this work for hg?
- }
- if (currentBranch != null) {
- Condition condition = myDataHolder.getContainingBranchesGetter().getContainedInBranchCondition(currentBranch, details.getRoot());
- if (condition.value(details.getId())) {
- return VcsCommitStyleFactory.background(CURRENT_BRANCH_BG);
- }
+ VcsLogProvider provider = myDataHolder.getLogProvider(details.getRoot());
+ String currentBranch = provider.getCurrentBranch(details.getRoot());
+ if (currentBranch != null) {
+ Condition condition = myDataHolder.getContainingBranchesGetter().getContainedInBranchCondition(currentBranch, details.getRoot());
+ if (condition.value(details.getId())) {
+ return VcsCommitStyleFactory.background(CURRENT_BRANCH_BG);
}
}
}
diff --git a/platform/vcs-log/impl/test/com/intellij/vcs/log/impl/TestVcsLogProvider.java b/platform/vcs-log/impl/test/com/intellij/vcs/log/impl/TestVcsLogProvider.java
index ed582cb83cbf..4728e2ea7ccd 100644
--- a/platform/vcs-log/impl/test/com/intellij/vcs/log/impl/TestVcsLogProvider.java
+++ b/platform/vcs-log/impl/test/com/intellij/vcs/log/impl/TestVcsLogProvider.java
@@ -210,6 +210,12 @@ public class TestVcsLogProvider implements VcsLogProvider {
return null;
}
+ @Nullable
+ @Override
+ public String getCurrentBranch(@NotNull VirtualFile root) {
+ return null;
+ }
+
private static class MockRefManager implements VcsLogRefManager {
public static final Comparator FAKE_COMPARATOR = new Comparator() {
diff --git a/plugins/git4idea/src/git4idea/log/GitLogProvider.java b/plugins/git4idea/src/git4idea/log/GitLogProvider.java
index 2eccb70ec977..07aafb4c1486 100644
--- a/plugins/git4idea/src/git4idea/log/GitLogProvider.java
+++ b/plugins/git4idea/src/git4idea/log/GitLogProvider.java
@@ -485,6 +485,18 @@ public class GitLogProvider implements VcsLogProvider {
return GitBranchUtil.getBranches(myProject, root, true, true, commitHash.asString());
}
+ @Nullable
+ @Override
+ public String getCurrentBranch(@NotNull VirtualFile root) {
+ GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
+ if (repository == null) return null;
+ String currentBranchName = repository.getCurrentBranchName();
+ if (currentBranchName == null && repository.getCurrentRevision() != null) {
+ return "HEAD";
+ }
+ return currentBranchName;
+ }
+
@Nullable
@Override
public T getPropertyValue(VcsLogProperties.VcsLogProperty property) {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
index fc64866f7889..ea99a67bdd19 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
@@ -274,6 +274,14 @@ public class HgLogProvider implements VcsLogProvider {
return HgHistoryUtil.getDescendingHeadsOfBranches(myProject, root, commitHash);
}
+ @Nullable
+ @Override
+ public String getCurrentBranch(@NotNull VirtualFile root) {
+ HgRepository repository = myRepositoryManager.getRepositoryForRoot(root);
+ if (repository == null) return null;
+ return repository.getCurrentBranchName();
+ }
+
@Nullable
@Override
public T getPropertyValue(VcsLogProperties.VcsLogProperty property) {