mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-86854 GitLog should not be available with all projects closed or should work - IAE at com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier.showOverVersionControlView
This commit is contained in:
@@ -419,9 +419,11 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
final String executable = myAppSettings.getPathToGit();
|
||||
try {
|
||||
myVersion = GitVersion.identifyVersion(executable);
|
||||
if (!myVersion.isSupported() && !myProject.isDefault()) {
|
||||
if (! myVersion.isSupported()) {
|
||||
String message = GitBundle.message("vcs.unsupported.version", myVersion, GitVersion.MIN);
|
||||
showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
|
||||
if (! myProject.isDefault()) {
|
||||
showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
|
||||
}
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -104,13 +104,14 @@ public class LowLevelAccessImpl implements LowLevelAccess {
|
||||
// uses cached version
|
||||
public CachedRefs getRefs() throws VcsException {
|
||||
final CachedRefs refs = new CachedRefs();
|
||||
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot);
|
||||
GitRepository repository = myProject == null || myProject.isDefault() ? null : GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot);
|
||||
if (repository == null) {
|
||||
final File child = new File(myRoot.getPath(), GitUtil.DOT_GIT);
|
||||
if (! child.exists()) {
|
||||
throw new VcsException("No git repository in " + myRoot.getPath());
|
||||
}
|
||||
repository = GitRepositoryImpl.getLightInstance(myRoot, myProject, myProject);
|
||||
repository.update(GitRepository.TrackedTopic.BRANCHES);
|
||||
repository.getBranches();
|
||||
}
|
||||
GitBranchesCollection branches = repository.getBranches();
|
||||
|
||||
@@ -444,7 +444,9 @@ public class BigTableTableModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public int getLastForRoot(final VirtualFile root) {
|
||||
return myRepoIdxMap.get(root).last();
|
||||
final TreeSet<Integer> integers = myRepoIdxMap.get(root);
|
||||
if (integers.isEmpty()) return -1;
|
||||
return integers.last();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-4
@@ -71,7 +71,10 @@ public class SelectRepositoryAndShowLogAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
project = project == null ? ProjectManager.getInstance().getDefaultProject() : project;
|
||||
final Project finalProject = project;
|
||||
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, true, false, true);
|
||||
final VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, project, null);
|
||||
if (virtualFiles.length == 0) return;
|
||||
@@ -106,13 +109,12 @@ public class SelectRepositoryAndShowLogAction extends AnAction {
|
||||
}
|
||||
|
||||
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
|
||||
final Project finalProject = project;
|
||||
|
||||
final Runnable showContent = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ContentManager cm = window.getContentManager();
|
||||
if (checkForProjectScope(cm, project, correctRoots)) return;
|
||||
if (checkForProjectScope(cm, finalProject, correctRoots)) return;
|
||||
|
||||
int cnt = 0;
|
||||
Content[] contents = cm.getContents();
|
||||
@@ -123,7 +125,7 @@ public class SelectRepositoryAndShowLogAction extends AnAction {
|
||||
List<VirtualFile> roots = ((MyContentComponent)component).getRoots();
|
||||
if (Comparing.equal(roots, correctRoots)) {
|
||||
cm.setSelectedContent(content);
|
||||
alreadyOpened(project);
|
||||
alreadyOpened(finalProject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -252,6 +254,10 @@ public class SelectRepositoryAndShowLogAction extends AnAction {
|
||||
GitVcs vcs = GitVcs.getInstance(myProject);
|
||||
if (vcs == null) { return; }
|
||||
myVersion = vcs.getVersion();
|
||||
if (myVersion.isNull()) {
|
||||
vcs.checkVersion();
|
||||
myVersion = vcs.getVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ public class GitRepositoryImpl implements GitRepository, Disposable {
|
||||
* If you need to have an instance of GitRepository for a repository outside the project, use
|
||||
* {@link #getLightInstance(com.intellij.openapi.vfs.VirtualFile, com.intellij.openapi.project.Project, com.intellij.openapi.Disposable)}.
|
||||
*/
|
||||
private GitRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project, @NotNull Disposable parentDisposable) {
|
||||
private GitRepositoryImpl(@NotNull VirtualFile rootDir, @NotNull Project project, @NotNull Disposable parentDisposable,
|
||||
final boolean light) {
|
||||
myRootDir = rootDir;
|
||||
myProject = project;
|
||||
Disposer.register(parentDisposable, this);
|
||||
@@ -71,12 +72,16 @@ public class GitRepositoryImpl implements GitRepository, Disposable {
|
||||
|
||||
myReader = new GitRepositoryReader(VfsUtil.virtualToIoFile(myGitDir));
|
||||
|
||||
myUntrackedFilesHolder = new GitUntrackedFilesHolder(this);
|
||||
Disposer.register(this, myUntrackedFilesHolder);
|
||||
|
||||
myMessageBus = project.getMessageBus();
|
||||
myNotifier = new QueueProcessor<Object>(new NotificationConsumer(myProject, myMessageBus), myProject.getDisposed());
|
||||
update(TrackedTopic.ALL);
|
||||
if (! light) {
|
||||
myUntrackedFilesHolder = new GitUntrackedFilesHolder(this);
|
||||
Disposer.register(this, myUntrackedFilesHolder);
|
||||
|
||||
update(TrackedTopic.ALL);
|
||||
} else {
|
||||
myUntrackedFilesHolder = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +91,7 @@ public class GitRepositoryImpl implements GitRepository, Disposable {
|
||||
*/
|
||||
@NotNull
|
||||
public static GitRepository getLightInstance(@NotNull VirtualFile root, @NotNull Project project, @NotNull Disposable parentDisposable) {
|
||||
return new GitRepositoryImpl(root, project, parentDisposable);
|
||||
return new GitRepositoryImpl(root, project, parentDisposable, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +99,7 @@ public class GitRepositoryImpl implements GitRepository, Disposable {
|
||||
* This is used for repositories registered in project, and should be optained via {@link GitRepositoryManager}.
|
||||
*/
|
||||
public static GitRepository getFullInstance(@NotNull VirtualFile root, @NotNull Project project, @NotNull Disposable parentDisposable) {
|
||||
GitRepositoryImpl repository = new GitRepositoryImpl(root, project, parentDisposable);
|
||||
GitRepositoryImpl repository = new GitRepositoryImpl(root, project, parentDisposable, false);
|
||||
repository.myUntrackedFilesHolder.setupVfsListener(project);
|
||||
repository.setupUpdater();
|
||||
return repository;
|
||||
|
||||
Reference in New Issue
Block a user