diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java index c5280218d3f7..e858cfad0f04 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java @@ -55,6 +55,7 @@ import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.text.DateFormatUtil; import com.intellij.vcs.log.TimedVcsCommit; import com.intellij.vcs.log.VcsFullCommitDetails; +import com.intellij.vcsUtil.VcsImplUtil; import com.intellij.vcsUtil.VcsUtil; import org.intellij.images.editor.ImageFileEditor; import org.jetbrains.annotations.Contract; @@ -75,19 +76,13 @@ public class DvcsUtil { private static final int SHORT_HASH_LENGTH = 8; private static final int LONG_HASH_LENGTH = 40; + /** + * @deprecated use {@link VcsImplUtil#getShortVcsRootName} + */ @NotNull + @Deprecated public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) { - VirtualFile projectDir = project.getBaseDir(); - - String repositoryPath = root.getPresentableUrl(); - if (projectDir != null) { - String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar); - if (relativePath != null) { - repositoryPath = relativePath; - } - } - - return repositoryPath.isEmpty() ? root.getName() : repositoryPath; + return VcsImplUtil.getShortVcsRootName(project, root); } @NotNull @@ -281,8 +276,9 @@ public class DvcsUtil { @NotNull AbstractRepositoryManager manager, @Nullable String defaultRootPathValue) { T repository = manager.getRepositoryForRootQuick(guessVcsRoot(project, getSelectedFile(project))); - return repository != null ? repository - : manager.getRepositoryForRootQuick(guessRootForVcs(project, manager.getVcs(), defaultRootPathValue)); + return repository != null + ? repository + : manager.getRepositoryForRootQuick(guessRootForVcs(project, manager.getVcs(), defaultRootPathValue)); } @Nullable diff --git a/platform/vcs-impl/src/com/intellij/vcsUtil/VcsImplUtil.java b/platform/vcs-impl/src/com/intellij/vcsUtil/VcsImplUtil.java index 542a74056f69..84eb0b1eb066 100644 --- a/platform/vcs-impl/src/com/intellij/vcsUtil/VcsImplUtil.java +++ b/platform/vcs-impl/src/com/intellij/vcsUtil/VcsImplUtil.java @@ -17,7 +17,12 @@ package com.intellij.vcsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.WaitForProgressToShow; +import org.jetbrains.annotations.NotNull; + +import java.io.File; /** *

{@link VcsUtil} extension that needs access to the vcs-impl module.

@@ -38,4 +43,19 @@ public class VcsImplUtil { Runnable task = new Runnable() { public void run() { Messages.showErrorDialog(project, message, title); } }; WaitForProgressToShow.runOrInvokeLaterAboveProgress(task, null, project); } + + @NotNull + public static String getShortVcsRootName(@NotNull Project project, @NotNull VirtualFile root) { + VirtualFile projectDir = project.getBaseDir(); + + String repositoryPath = root.getPresentableUrl(); + if (projectDir != null) { + String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar); + if (relativePath != null) { + repositoryPath = relativePath; + } + } + + return repositoryPath.isEmpty() ? root.getName() : repositoryPath; + } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java index 75efe55d968e..c3984ac80b5c 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java @@ -34,6 +34,7 @@ import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.ui.VcsLogColorManager; import com.intellij.vcs.log.ui.frame.VcsLogGraphTable; +import com.intellij.vcsUtil.VcsImplUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,7 +65,7 @@ public class GoToHashOrRefPopup { @NotNull Comparator comparator) { myOnSelectedHash = onSelectedHash; myOnSelectedRef = onSelectedRef; - myTextField = new TextFieldWithProgress(project, new VcsRefCompletionProvider(variants, colorManager, comparator)) { + myTextField = new TextFieldWithProgress(project, new VcsRefCompletionProvider(project, variants, colorManager, comparator)) { @Override public void onOk() { if (myFuture == null) { @@ -147,13 +148,16 @@ public class GoToHashOrRefPopup { } private class VcsRefCompletionProvider extends TextFieldWithAutoCompletionListProvider { + @NotNull private final Project myProject; @NotNull private final VcsLogColorManager myColorManager; @NotNull private final Comparator myReferenceComparator; - public VcsRefCompletionProvider(@NotNull Collection variants, + public VcsRefCompletionProvider(@NotNull Project project, + @NotNull Collection variants, @NotNull VcsLogColorManager colorManager, @NotNull Comparator comparator) { super(variants); + myProject = project; myColorManager = colorManager; myReferenceComparator = comparator; } @@ -192,7 +196,7 @@ public class GoToHashOrRefPopup { @Override protected String getTypeText(@NotNull VcsRef item) { if (!myColorManager.isMultipleRoots()) return null; - return item.getRoot().getName(); + return VcsImplUtil.getShortVcsRootName(myProject, item.getRoot()); } @Override diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index c9d70532db12..afe5944a4384 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -15,7 +15,6 @@ */ package git4idea.update; -import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; @@ -26,6 +25,7 @@ import com.intellij.openapi.vcs.VcsNotifier; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; +import com.intellij.vcsUtil.VcsImplUtil; import git4idea.GitLocalBranch; import git4idea.GitRemoteBranch; import git4idea.GitUtil; @@ -298,7 +298,7 @@ public class GitFetcher { StringBuilder info = new StringBuilder(); if (myRepositoryManager.moreThanOneRoot()) { for (Map.Entry entry : additionalInfo.entrySet()) { - info.append(entry.getValue()).append(" in ").append(DvcsUtil.getShortRepositoryName(myProject, entry.getKey())).append("
"); + info.append(entry.getValue()).append(" in ").append(VcsImplUtil.getShortVcsRootName(myProject, entry.getKey())).append("
"); } } else {