mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
GitRepository: no refresh, only update
This commit is contained in:
@@ -38,7 +38,11 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
* </p>
|
||||
* <p>
|
||||
* The GitRepository is updated "externally" by the {@link git4idea.repo.GitRepositoryUpdater}, when correspondent .git service files
|
||||
* change. To force the update procedure call {@link #refresh()}.
|
||||
* change. To force asynchronous update, it is enough to call {@link VirtualFile#refresh(boolean, boolean) refresh} on the root directory.
|
||||
* </p>
|
||||
* <p>
|
||||
* To make a synchronous update of the repository call {@link #update(TrackedTopic...)} and specify
|
||||
* which topics should be updated. Updating requires reading from disk, so updating {@link GitRepository.TrackedTopic.ALL} may take some time.
|
||||
* </p>
|
||||
* <p>
|
||||
* Other components may subscribe to GitRepository changes via the {@link #GIT_REPO_CHANGE} {@link Topic}
|
||||
@@ -223,14 +227,6 @@ public final class GitRepository implements Disposable {
|
||||
connection.subscribe(GIT_REPO_CHANGE, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the .git directory asynchronously.
|
||||
* Call this method after performing write operations on the Git repository: such as commit, fetch, reset, etc.
|
||||
*/
|
||||
public void refresh() {
|
||||
myGitDir.refresh(true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously updates the GitRepository by reading information from the specified topics.
|
||||
*/
|
||||
|
||||
@@ -124,15 +124,6 @@ public final class GitRepositoryManager extends AbstractProjectComponent impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously refreshes all {@link GitRepository GitRepositories}.
|
||||
*/
|
||||
public void refreshAllRepositories() {
|
||||
for (GitRepository repository : getRepositories()) {
|
||||
repository.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously updates the specified information about Git repository under the given root.
|
||||
* @param root root directory of the Git repository.
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.util.continuation.*;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
|
||||
/**
|
||||
@@ -33,14 +34,17 @@ import git4idea.repo.GitRepositoryManager;
|
||||
public abstract class GitUpdateLikeProcess {
|
||||
public static final String GIT_UPDATING = "Git: updating";
|
||||
public static final String REASON = "Local changes are not available until Git update is finished.";
|
||||
|
||||
private final Project myProject;
|
||||
private GeneralSettings myGeneralSettings;
|
||||
private ProjectManagerEx myProjectManager;
|
||||
private final GeneralSettings myGeneralSettings;
|
||||
private final ProjectManagerEx myProjectManager;
|
||||
private final GitRepositoryManager myRepositoryManager;
|
||||
|
||||
public GitUpdateLikeProcess(final Project project) {
|
||||
myProject = project;
|
||||
myGeneralSettings = GeneralSettings.getInstance();
|
||||
myProjectManager = ProjectManagerEx.getInstanceEx();
|
||||
myRepositoryManager = GitRepositoryManager.getInstance(project);
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@@ -71,7 +75,6 @@ public abstract class GitUpdateLikeProcess {
|
||||
myProjectManager.unblockReloadingProjectOnExternalChanges();
|
||||
myGeneralSettings.setSaveOnFrameDeactivation(saveOnFrameDeactivation);
|
||||
myGeneralSettings.setSyncOnFrameActivation(syncOnFrameDeactivation);
|
||||
GitRepositoryManager.getInstance(myProject).refreshAllRepositories();
|
||||
changeListManager.letGo();
|
||||
}
|
||||
};
|
||||
@@ -87,11 +90,25 @@ public abstract class GitUpdateLikeProcess {
|
||||
public void run(final ContinuationContext context) {
|
||||
runImpl(context);
|
||||
}
|
||||
}, returnFlagsBack};
|
||||
},
|
||||
new TaskDescriptor(GIT_UPDATING, Where.POOLED) {
|
||||
@Override
|
||||
public void run(ContinuationContext context) {
|
||||
updateRepositories();
|
||||
}
|
||||
},
|
||||
returnFlagsBack
|
||||
};
|
||||
returnFlagsBack.setHaveMagicCure(true);
|
||||
initContext.next(next);
|
||||
continuation.run(initContext.getList());
|
||||
}
|
||||
|
||||
private void updateRepositories() {
|
||||
for (GitRepository repo: myRepositoryManager.getRepositories()) {
|
||||
repo.update(GitRepository.TrackedTopic.ALL);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void runImpl(ContinuationContext context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user