use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class FetchBackgroundable method run.
@Override
@UIThreadUnsafe
public void run(ProgressIndicator indicator) {
if (taskSubtitle != null) {
// This method set a text under a progress bar (despite of docstring)
indicator.setText(taskSubtitle);
}
val fetchSupport = GitFetchSupport.fetchSupport(project);
GitRemote remote = remoteName.equals(LOCAL_REPOSITORY_NAME) ? GitRemote.DOT : GitUtil.findRemoteByName(gitRepository, remoteName);
if (remote == null) {
// This is generally NOT expected, the task should never be triggered
// for an invalid remote in the first place.
LOG.warn("Remote '${remoteName}' does not exist");
return;
}
val fetchResult = fetchSupport.fetch(gitRepository, remote, refspec);
fetchResult.showNotificationIfFailed(failureNotificationText);
fetchResult.throwExceptionIfFailed();
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class GitCommandUpdatingCurrentBranchBackgroundable method deriveGitUpdatedRanges.
@UIThreadUnsafe
@Nullable
private GitUpdatedRanges deriveGitUpdatedRanges(String targetBranchName) {
GitUpdatedRanges updatedRanges = null;
val currentBranch = gitRepository.getCurrentBranch();
if (currentBranch != null) {
GitBranch targetBranch = gitRepository.getBranches().findBranchByName(targetBranchName);
if (targetBranch != null) {
GitBranchPair refPair = new GitBranchPair(currentBranch, targetBranch);
updatedRanges = GitUpdatedRanges.calcInitialPositions(project, java.util.Collections.singletonMap(gitRepository, refPair));
} else {
LOG.warn("Couldn't find the branch with name '${targetBranchName}'");
}
}
return updatedRanges;
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class GitCommandUpdatingCurrentBranchBackgroundable method run.
@Override
@UIThreadUnsafe
public final void run(ProgressIndicator indicator) {
val handler = createGitLineHandler();
if (handler == null) {
return;
}
val localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(gitRepository.getRoot(), MERGE);
val untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(gitRepository.getRoot());
handler.addLineListener(localChangesDetector);
handler.addLineListener(untrackedFilesDetector);
Label beforeLabel = LocalHistory.getInstance().putSystemLabel(project, /* name */
"Before update");
GitUpdatedRanges updatedRanges = deriveGitUpdatedRanges(getTargetBranchName());
String beforeRevision = gitRepository.getCurrentRevision();
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, getOperationName())) {
GitCommandResult result = Git.getInstance().runCommand(handler);
if (beforeRevision != null) {
GitRevisionNumber currentRev = new GitRevisionNumber(beforeRevision);
handleResult(result, localChangesDetector, untrackedFilesDetector, currentRev, beforeLabel, updatedRanges);
}
}
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class GitCommandUpdatingCurrentBranchBackgroundable method showUpdates.
@UIThreadUnsafe
private void showUpdates(GitRevisionNumber currentRev, Label beforeLabel) {
try {
UpdatedFiles files = UpdatedFiles.create();
val collector = createMergeChangeCollector(project, gitRepository, currentRev);
collector.collect(files);
UiThreadExecutionCompat.invokeLaterIfNeeded(ModalityState.defaultModalityState(), () -> {
val manager = ProjectLevelVcsManagerEx.getInstanceEx(project);
UpdateInfoTree tree = manager.showUpdateProjectInfo(files, getOperationName(), ActionInfo.UPDATE, /* canceled */
false);
if (tree != null) {
tree.setBefore(beforeLabel);
tree.setAfter(LocalHistory.getInstance().putSystemLabel(project, /* name */
"After update"));
ViewUpdateInfoNotification.focusUpdateInfoTree(project, tree);
}
});
} catch (VcsException e) {
GitVcs.getInstance(project).showErrors(java.util.Collections.singletonList(e), getOperationName());
}
}
use of com.virtuslab.qual.guieffect.UIThreadUnsafe in project git-machete-intellij-plugin by VirtusLab.
the class PullCurrentBranchFastForwardOnlyBackgroundable method createGitLineHandler.
@Override
@UIThreadUnsafe
@Nullable
protected GitLineHandler createGitLineHandler() {
val handler = new GitLineHandler(project, gitRepository.getRoot(), GitCommand.PULL);
String remoteName = remoteBranch.getRemoteName();
GitRemote remote = GitUtil.findRemoteByName(gitRepository, remoteName);
if (remote == null) {
// This is generally NOT expected, the task should never be triggered
// for an invalid remote in the first place.
LOG.warn("Remote '${remoteName}' does not exist");
return null;
}
handler.setUrls(remote.getUrls());
handler.addParameters("--ff-only");
handler.addParameters(remote.getName());
val remoteBranchFullNameAsLocalBranchOnRemote = remoteBranch.getFullNameAsLocalBranchOnRemote();
val remoteBranchFullName = remoteBranch.getFullName();
// This strategy is used to fetch branch from remote repository to remote branch in our repository.
String refspec = createRefspec(remoteBranchFullNameAsLocalBranchOnRemote, remoteBranchFullName, /* allowNonFastForward */
true);
handler.addParameters(refspec);
return handler;
}
Aggregations