mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
HeavyProcessLatch API slightly changed to handle overlapping processes correctly
This commit is contained in:
+3
-2
@@ -19,6 +19,7 @@ import com.intellij.compiler.server.BuildManager;
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
@@ -352,7 +353,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
public void reset() {
|
||||
// need this to ensure VFS operations will not block because of storage flushing
|
||||
// and other maintenance IO tasks run in background
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Resetting Project Structure");
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Resetting Project Structure");
|
||||
|
||||
try {
|
||||
myWasUiDisposed = false;
|
||||
@@ -387,7 +388,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.dvcs;
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.dvcs.repo.RepositoryManager;
|
||||
import com.intellij.ide.file.BatchFileChangeListener;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -189,13 +190,14 @@ public class DvcsUtil {
|
||||
return DateFormatUtil.formatPrettyDateTime(commit.getTimestamp()) + " ";
|
||||
}
|
||||
|
||||
public static void workingTreeChangeStarted(@NotNull Project project) {
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Changing DVCS working tree");
|
||||
@NotNull
|
||||
public static AccessToken workingTreeChangeStarted(@NotNull Project project) {
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeStarted(project);
|
||||
return HeavyProcessLatch.INSTANCE.processStarted("Changing DVCS working tree");
|
||||
}
|
||||
|
||||
public static void workingTreeChangeFinished(@NotNull Project project) {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
public static void workingTreeChangeFinished(@NotNull Project project, @NotNull AccessToken token) {
|
||||
token.finish();
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeCompleted(project);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ide.startup.impl;
|
||||
|
||||
import com.intellij.ide.caches.CacheUpdater;
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -113,7 +114,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
@Override
|
||||
@SuppressWarnings("SynchronizeOnThis")
|
||||
public void run() {
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Running Startup Activities");
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Running Startup Activities");
|
||||
try {
|
||||
runActivities(myPreStartupActivities);
|
||||
|
||||
@@ -133,7 +134,7 @@ public class StartupManagerImpl extends StartupManagerEx {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -502,7 +502,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
myIsFiringLoadingEvent = false;
|
||||
}
|
||||
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Loading application components");
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Loading application components");
|
||||
try {
|
||||
store.load();
|
||||
}
|
||||
@@ -510,7 +510,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
}
|
||||
myLoaded = true;
|
||||
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.BaseComponent;
|
||||
import com.intellij.openapi.components.ComponentConfig;
|
||||
@@ -199,7 +200,7 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
@Override
|
||||
public Object compute() {
|
||||
// prevent storages from flushing and blocking FS
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Creating component '" + myDescriptor.getImplementation()+"'");
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Creating component '" + myDescriptor.getImplementation() + "'");
|
||||
try {
|
||||
synchronized (MyComponentAdapter.this) {
|
||||
Object instance = myInitializedComponentInstance;
|
||||
@@ -209,7 +210,7 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.project;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.caches.CacheUpdater;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -152,12 +153,12 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
if (indicator != null) {
|
||||
indicator.pushState();
|
||||
}
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Performing indexing task");
|
||||
try {
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Performing indexing task");
|
||||
task.performInDumbMode(indicator != null ? indicator : new EmptyProgressIndicator());
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
if (indicator != null) {
|
||||
indicator.popState();
|
||||
}
|
||||
@@ -336,8 +337,8 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
public void run(@NotNull final ProgressIndicator visibleIndicator) {
|
||||
final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance();
|
||||
final Thread self = Thread.currentThread();
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks");
|
||||
try {
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks");
|
||||
shutdownTracker.registerStopperThread(self);
|
||||
|
||||
if (visibleIndicator instanceof ProgressIndicatorEx) {
|
||||
@@ -362,7 +363,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
|
||||
}
|
||||
finally {
|
||||
shutdownTracker.unregisterStopperThread(self);
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs.newvfs;
|
||||
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -74,12 +75,12 @@ public class RefreshQueueImpl extends RefreshQueue {
|
||||
public void run() {
|
||||
try {
|
||||
myRefreshIndicator.start();
|
||||
HeavyProcessLatch.INSTANCE.processStarted("Doing file refresh. "+session.toString());
|
||||
AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Doing file refresh. " + session.toString());
|
||||
try {
|
||||
doScan(session);
|
||||
}
|
||||
finally {
|
||||
HeavyProcessLatch.INSTANCE.processFinished();
|
||||
token.finish();
|
||||
myRefreshIndicator.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,18 @@
|
||||
package com.intellij.util.io.storage;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EventListener;
|
||||
import java.util.Stack;
|
||||
import java.util.Set;
|
||||
|
||||
public class HeavyProcessLatch {
|
||||
public static final HeavyProcessLatch INSTANCE = new HeavyProcessLatch();
|
||||
|
||||
private final Stack<String> myHeavyProcesses = new Stack<String>();
|
||||
private final Set<String> myHeavyProcesses = new ConcurrentHashSet<String>();
|
||||
private final EventDispatcher<HeavyProcessListener> myEventDispatcher = EventDispatcher.create(HeavyProcessListener.class);
|
||||
|
||||
private HeavyProcessLatch() {
|
||||
@@ -43,13 +45,21 @@ public class HeavyProcessLatch {
|
||||
processStarted("");
|
||||
}
|
||||
|
||||
public void processStarted(@NotNull String operationName) {
|
||||
myHeavyProcesses.push(operationName);
|
||||
@NotNull
|
||||
public AccessToken processStarted(@NotNull final String operationName) {
|
||||
myHeavyProcesses.add(operationName);
|
||||
myEventDispatcher.getMulticaster().processStarted();
|
||||
return new AccessToken() {
|
||||
@Override
|
||||
public void finish() {
|
||||
myHeavyProcesses.remove(operationName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Deprecated // use processStarted(String)
|
||||
public void processFinished() {
|
||||
myHeavyProcesses.pop();
|
||||
myHeavyProcesses.remove("");
|
||||
myEventDispatcher.getMulticaster().processFinished();
|
||||
}
|
||||
|
||||
@@ -59,7 +69,7 @@ public class HeavyProcessLatch {
|
||||
|
||||
public String getRunningOperationName() {
|
||||
synchronized (myHeavyProcesses) {
|
||||
return myHeavyProcesses.isEmpty() ? null : myHeavyProcesses.peek();
|
||||
return myHeavyProcesses.isEmpty() ? null : myHeavyProcesses.iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package git4idea.actions;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.history.Label;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -86,7 +87,7 @@ abstract class GitMergeAction extends GitRepositoryAction {
|
||||
final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector =
|
||||
new GitUntrackedFilesOverwrittenByOperationDetector(selectedRoot);
|
||||
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
GitCommandResult result = git.runCommand(new Computable<GitLineHandler>() {
|
||||
@Override
|
||||
@@ -109,7 +110,7 @@ abstract class GitMergeAction extends GitRepositoryAction {
|
||||
handleResult(result, project, localChangesDetector, untrackedFilesDetector, repository, currentRev, affectedRoots, beforeLabel);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package git4idea.actions;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -75,12 +76,12 @@ public class GitRebaseAbort extends GitRepositoryAction {
|
||||
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REBASE);
|
||||
h.setStdoutSuppressed(false);
|
||||
h.addParameters("--abort");
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
GitHandlerUtil.doSynchronously(h, getActionName(), h.printableCommandLine());
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -65,7 +66,7 @@ public abstract class GitRebaseActionBase extends GitRepositoryAction {
|
||||
task.executeInBackground(false, new GitTaskResultHandlerAdapter() {
|
||||
@Override
|
||||
protected void run(GitTaskResult taskResult) {
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
editor.close();
|
||||
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
|
||||
@@ -74,7 +75,7 @@ public abstract class GitRebaseActionBase extends GitRepositoryAction {
|
||||
notifyAboutErrorResult(taskResult, resultListener, exceptions, project);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -57,12 +58,12 @@ public class GitResetHead extends GitRepositoryAction {
|
||||
}
|
||||
GitLineHandler h = d.handler();
|
||||
affectedRoots.add(d.getGitRoot());
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
GitHandlerUtil.doSynchronously(h, GitBundle.getString("resetting.title"), h.printableCommandLine());
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
|
||||
manager.updateRepository(d.getGitRoot());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -54,12 +55,12 @@ public class GitStash extends GitRepositoryAction {
|
||||
VirtualFile root = d.getGitRoot();
|
||||
affectedRoots.add(root);
|
||||
final GitLineHandler h = d.handler();
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
GitHandlerUtil.doSynchronously(h, GitBundle.getString("stashing.title"), h.printableCommandLine());
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.branch;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -65,7 +66,7 @@ class GitCheckoutOperation extends GitBranchOperation {
|
||||
protected void execute() {
|
||||
saveAllDocuments();
|
||||
boolean fatalErrorHappened = false;
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
while (hasMoreRepositories() && !fatalErrorHappened) {
|
||||
final GitRepository repository = next();
|
||||
@@ -104,7 +105,7 @@ class GitCheckoutOperation extends GitBranchOperation {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
|
||||
if (!fatalErrorHappened) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package git4idea.branch;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -73,7 +74,7 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
saveAllDocuments();
|
||||
boolean fatalErrorHappened = false;
|
||||
int alreadyUpToDateRepositories = 0;
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
while (hasMoreRepositories() && !fatalErrorHappened) {
|
||||
final GitRepository repository = next();
|
||||
@@ -147,7 +148,7 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
restoreLocalChanges();
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package git4idea.cherrypick;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -90,7 +91,7 @@ public class GitCherryPicker {
|
||||
public void cherryPick(@NotNull Map<GitRepository, List<VcsFullCommitDetails>> commitsInRoots) {
|
||||
List<GitCommitWrapper> successfulCommits = ContainerUtil.newArrayList();
|
||||
List<GitCommitWrapper> alreadyPicked = ContainerUtil.newArrayList();
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
for (Map.Entry<GitRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) {
|
||||
GitRepository repository = entry.getKey();
|
||||
@@ -103,7 +104,7 @@ public class GitCherryPicker {
|
||||
notifyResult(successfulCommits, alreadyPicked);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.rebase;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -91,8 +92,8 @@ public class GitRebaser {
|
||||
rebaseTask.setProgressAnalyzer(new GitStandardProgressAnalyzer());
|
||||
final AtomicReference<GitUpdateResult> updateResult = new AtomicReference<GitUpdateResult>();
|
||||
final AtomicBoolean failure = new AtomicBoolean();
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
rebaseTask.executeInBackground(true, new GitTaskResultHandlerAdapter() {
|
||||
@Override
|
||||
protected void onSuccess() {
|
||||
@@ -118,7 +119,7 @@ public class GitRebaser {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
return updateResult.get();
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public class GitRebaser {
|
||||
* @return true if rebase successfully finished.
|
||||
*/
|
||||
public boolean continueRebase(@NotNull Collection<VirtualFile> rebasingRoots) {
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
boolean success = true;
|
||||
for (VirtualFile root : rebasingRoots) {
|
||||
@@ -155,7 +156,7 @@ public class GitRebaser {
|
||||
return success;
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package git4idea.reset;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.dvcs.repo.RepositoryUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -76,7 +77,7 @@ public class GitResetOperation {
|
||||
|
||||
public void execute() {
|
||||
saveAllDocuments();
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
Map<GitRepository, GitCommandResult> results = ContainerUtil.newHashMap();
|
||||
try {
|
||||
for (Map.Entry<GitRepository, VcsFullCommitDetails> entry : myCommits.entrySet()) {
|
||||
@@ -99,7 +100,7 @@ public class GitResetOperation {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
notifyResult(results);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package git4idea.rollback;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -142,7 +143,7 @@ public class GitRollbackEnvironment implements RollbackEnvironment {
|
||||
}
|
||||
}
|
||||
// revert files from HEAD
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
for (Map.Entry<VirtualFile, List<FilePath>> entry : toRevert.entrySet()) {
|
||||
listener.accept(entry.getValue());
|
||||
@@ -155,7 +156,7 @@ public class GitRollbackEnvironment implements RollbackEnvironment {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject,token);
|
||||
}
|
||||
LocalFileSystem lfs = LocalFileSystem.getInstance();
|
||||
HashSet<File> filesToRefresh = new HashSet<File>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -357,7 +358,7 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
h.addLineListener(untrackedFilesDetector);
|
||||
h.addLineListener(localChangesDetector);
|
||||
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
final Ref<GitCommandResult> result = Ref.create();
|
||||
ProgressManager.getInstance().run(new Task.Modal(h.project(), GitBundle.getString("unstash.unstashing"), false) {
|
||||
@@ -384,7 +385,7 @@ public class GitUnstashDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package git4idea.update;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
@@ -133,12 +134,12 @@ public class GitUpdateProcess {
|
||||
|
||||
GitComplexProcess.Operation updateOperation = new GitComplexProcess.Operation() {
|
||||
@Override public void run(ContinuationContext continuationContext) {
|
||||
DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
|
||||
try {
|
||||
myResult = updateImpl(updateMethod, continuationContext);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(myProject);
|
||||
DvcsUtil.workingTreeChangeFinished(myProject, token);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.github;
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -229,18 +230,22 @@ public class GithubRebaseAction extends DumbAwareAction {
|
||||
@NotNull final ProgressIndicator indicator) {
|
||||
final Git git = ServiceManager.getService(project, Git.class);
|
||||
final GitPlatformFacade facade = ServiceManager.getService(project, GitPlatformFacade.class);
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
GitPreservingProcess process =
|
||||
new GitPreservingProcess(project, facade, git, Collections.singletonList(gitRepository), "Rebasing", "upstream/master", indicator,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doRebaseCurrentBranch(project, gitRepository.getRoot(), indicator);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
GitPreservingProcess process =
|
||||
new GitPreservingProcess(project, facade, git, Collections.singletonList(gitRepository), "Rebasing", "upstream/master", indicator,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doRebaseCurrentBranch(project, gitRepository.getRoot(), indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
process.execute();
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
);
|
||||
process.execute();
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
|
||||
private static void doRebaseCurrentBranch(@NotNull final Project project,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.zmlx.hg4idea.command;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -50,7 +51,7 @@ public class HgMergeCommand {
|
||||
arguments.add("--rev");
|
||||
arguments.add(revision);
|
||||
}
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
final HgCommandResult result =
|
||||
commandExecutor.executeInCurrentThread(repo, "merge", arguments);
|
||||
@@ -58,7 +59,7 @@ public class HgMergeCommand {
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.zmlx.hg4idea.command;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -50,7 +51,7 @@ public class HgRebaseCommand {
|
||||
|
||||
@Nullable
|
||||
private HgCommandResult performRebase(@NotNull String... args) {
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
HgCommandResult result =
|
||||
new HgCommandExecutor(project)
|
||||
@@ -60,7 +61,7 @@ public class HgRebaseCommand {
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.zmlx.hg4idea.command;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -75,7 +76,7 @@ public class HgUpdateCommand {
|
||||
final HgPromptCommandExecutor executor = new HgPromptCommandExecutor(project);
|
||||
executor.setShowOutput(true);
|
||||
HgCommandResult result;
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
result =
|
||||
executor.executeInCurrentThread(repo, "update", arguments);
|
||||
@@ -89,7 +90,7 @@ public class HgUpdateCommand {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
|
||||
project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.zmlx.hg4idea.provider;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
@@ -71,7 +72,7 @@ public class HgRollbackEnvironment implements RollbackEnvironment {
|
||||
}
|
||||
}
|
||||
}
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
revert(filePaths);
|
||||
for (FilePath file : toDelete) {
|
||||
@@ -92,18 +93,18 @@ public class HgRollbackEnvironment implements RollbackEnvironment {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
|
||||
public void rollbackMissingFileDeletion(List<FilePath> files,
|
||||
List<VcsException> exceptions, RollbackProgressListener listener) {
|
||||
DvcsUtil.workingTreeChangeStarted(project);
|
||||
AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
|
||||
try {
|
||||
revert(files);
|
||||
}
|
||||
finally {
|
||||
DvcsUtil.workingTreeChangeFinished(project);
|
||||
DvcsUtil.workingTreeChangeFinished(project, token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user