mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[hg] execute hg push synchronously and rename appropriate methods in Push Controller
This commit is contained in:
@@ -486,15 +486,15 @@ public class PushController implements Disposable {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
myPushSettings.saveExcludedRepoRoots(myExcludedRepositoryRoots);
|
||||
for (PushSupport support : myPushSupports) {
|
||||
doPush(support, force);
|
||||
doPushSynchronously(support, force);
|
||||
}
|
||||
}
|
||||
};
|
||||
task.queue();
|
||||
}
|
||||
|
||||
private <R extends Repository, S extends PushSource, T extends PushTarget> void doPush(@NotNull PushSupport<R, S, T> support,
|
||||
boolean force) {
|
||||
private <R extends Repository, S extends PushSource, T extends PushTarget> void doPushSynchronously(@NotNull PushSupport<R, S, T> support,
|
||||
boolean force) {
|
||||
VcsPushOptionValue options = myDialog.getAdditionalOptionValue(support);
|
||||
Pusher<R, S, T> pusher = support.getPusher();
|
||||
Map<R, PushSpec<S, T>> specs = collectPushSpecsForVcs(support);
|
||||
|
||||
@@ -16,10 +16,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgVcs;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResult;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResultHandler;
|
||||
import org.zmlx.hg4idea.execution.HgRemoteCommandExecutor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -63,7 +61,7 @@ public class HgPushCommand {
|
||||
myBookmarkName = bookmark;
|
||||
}
|
||||
|
||||
public void execute(final HgCommandResultHandler resultHandler) {
|
||||
public HgCommandResult executeInCurrentThread() {
|
||||
final List<String> arguments = new LinkedList<String>();
|
||||
if (!StringUtil.isEmptyOrSpaces(myRevision)) {
|
||||
arguments.add("-r");
|
||||
@@ -87,15 +85,9 @@ public class HgPushCommand {
|
||||
|
||||
final HgRemoteCommandExecutor executor = new HgRemoteCommandExecutor(myProject, myDestination);
|
||||
executor.setShowOutput(true);
|
||||
executor.execute(myRepo, "push", arguments, new HgCommandResultHandler() {
|
||||
@Override
|
||||
public void process(@Nullable HgCommandResult result) {
|
||||
if (!myProject.isDisposed()) {
|
||||
myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null);
|
||||
}
|
||||
resultHandler.process(result);
|
||||
}
|
||||
});
|
||||
HgCommandResult result = executor.executeInCurrentThread(myRepo, "push", arguments);
|
||||
myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
public VirtualFile getRepo() {
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.action.HgCommandResultNotifier;
|
||||
import org.zmlx.hg4idea.command.HgPushCommand;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResult;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResultHandler;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -70,35 +69,31 @@ public class HgPusher extends Pusher<HgRepository, HgPushSource, HgTarget> {
|
||||
else {
|
||||
pushCommand.setBranchName(branchName);
|
||||
}
|
||||
push(project, pushCommand);
|
||||
pushSynchronously(project, pushCommand);
|
||||
}
|
||||
}
|
||||
|
||||
public static void push(@NotNull final Project project, @NotNull HgPushCommand command) {
|
||||
public static void pushSynchronously(@NotNull final Project project, @NotNull HgPushCommand command) {
|
||||
final VirtualFile repo = command.getRepo();
|
||||
command.execute(new HgCommandResultHandler() {
|
||||
@Override
|
||||
public void process(@Nullable HgCommandResult result) {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
HgCommandResult result = command.executeInCurrentThread();
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.getExitValue() == PUSH_SUCCEEDED_EXIT_VALUE) {
|
||||
int commitsNum = getNumberOfPushedCommits(result);
|
||||
String successTitle = "Pushed successfully";
|
||||
String successDescription = String.format("Pushed %d %s [%s]", commitsNum, StringUtil.pluralize("commit", commitsNum),
|
||||
repo.getPresentableName());
|
||||
VcsNotifier.getInstance(project).notifySuccess(successTitle, successDescription);
|
||||
}
|
||||
else if (result.getExitValue() == NOTHING_TO_PUSH_EXIT_VALUE) {
|
||||
VcsNotifier.getInstance(project).notifySuccess("Nothing to push");
|
||||
}
|
||||
else {
|
||||
new HgCommandResultNotifier(project).notifyError(result, "Push failed",
|
||||
"Failed to push to [" + repo.getPresentableName() + "]");
|
||||
}
|
||||
}
|
||||
});
|
||||
if (result.getExitValue() == PUSH_SUCCEEDED_EXIT_VALUE) {
|
||||
int commitsNum = getNumberOfPushedCommits(result);
|
||||
String successTitle = "Pushed successfully";
|
||||
String successDescription = String.format("Pushed %d %s [%s]", commitsNum, StringUtil.pluralize("commit", commitsNum),
|
||||
repo.getPresentableName());
|
||||
VcsNotifier.getInstance(project).notifySuccess(successTitle, successDescription);
|
||||
}
|
||||
else if (result.getExitValue() == NOTHING_TO_PUSH_EXIT_VALUE) {
|
||||
VcsNotifier.getInstance(project).notifySuccess("Nothing to push");
|
||||
}
|
||||
else {
|
||||
new HgCommandResultNotifier(project).notifyError(result, "Push failed",
|
||||
"Failed to push to [" + repo.getPresentableName() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
static int getNumberOfPushedCommits(@NotNull HgCommandResult result) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.zmlx.hg4idea.test;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.testng.annotations.Test;
|
||||
import org.zmlx.hg4idea.command.HgPushCommand;
|
||||
import org.zmlx.hg4idea.execution.HgCommandResultHandler;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
@@ -56,8 +55,7 @@ public class HgPushTest extends HgCollaborativeTest {
|
||||
myChangeListManager.checkFilesAreInList(true, vf);
|
||||
myChangeListManager.commitFiles(vf);
|
||||
|
||||
final HgPushCommand command = new HgPushCommand(myProject, myRepo.getDir(), myParentRepo.getDir().getUrl());
|
||||
command.execute(HgCommandResultHandler.DUMB);
|
||||
new HgPushCommand(myProject, myRepo.getDir(), myParentRepo.getDir().getUrl()).executeInCurrentThread();
|
||||
|
||||
myParentRepo.update();
|
||||
assertNotNull(myParentRepo.getDir().findChild(AFILE));
|
||||
|
||||
Reference in New Issue
Block a user