In the case of auth error, show the notification.
Don't check for incoming/outgoing changes if pull finished with an error.
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
-import org.apache.commons.lang.StringUtils;
-import org.jetbrains.annotations.Nullable;
-import org.zmlx.hg4idea.HgFile;
-import org.zmlx.hg4idea.command.*;
-import org.zmlx.hg4idea.execution.HgCommandResult;
-import org.zmlx.hg4idea.execution.HgCommandResultHandler;
-import org.zmlx.hg4idea.provider.update.HgConflictResolver;
+import org.zmlx.hg4idea.command.HgMQCommand;
+import org.zmlx.hg4idea.command.HgPullCommand;
import org.zmlx.hg4idea.ui.HgPullDialog;
import java.util.Collection;
-import java.util.Map;
+// TODO unsued code. Keeping until MQ extension will be supported
public class HgMqRebaseAction extends HgAbstractGlobalAction {
protected HgGlobalCommandBuilder getHgGlobalCommandBuilder(final Project project) {
pullCommand.setRebase(true);
pullCommand.setUpdate(false);
- pullCommand.execute(new HgCommandResultHandler() {
- @Override
- public void process(@Nullable HgCommandResult result) {
- new HgCommandResultNotifier(project).process(result, null, null);
-
- String currentBranch = new HgTagBranchCommand(project, repository).getCurrentBranch();
- if (StringUtils.isBlank(currentBranch)) {
- return;
- }
-
- new HgConflictResolver(project).resolve(repository);
-
- HgResolveCommand resolveCommand = new HgResolveCommand(project);
- Map<HgFile, HgResolveStatusEnum> status = resolveCommand.getListSynchronously(repository);
-
- if (status.containsValue(HgResolveStatusEnum.UNRESOLVED)) {
- return;
- }
-
- new HgRebaseCommand(project, repository).continueRebase();
- }
- });
+ //pullCommand.execute(new HgCommandResultHandler() {
+ // @Override
+ // public void process(@Nullable HgCommandResult result) {
+ // new HgCommandResultNotifier(project).process(result, null, null);
+ //
+ // String currentBranch = new HgTagBranchCommand(project, repository).getCurrentBranch();
+ // if (StringUtils.isBlank(currentBranch)) {
+ // return;
+ // }
+ //
+ // new HgConflictResolver(project).resolve(repository);
+ //
+ // HgResolveCommand resolveCommand = new HgResolveCommand(project);
+ // Map<HgFile, HgResolveStatusEnum> status = resolveCommand.getListSynchronously(repository);
+ //
+ // if (status.containsValue(HgResolveStatusEnum.UNRESOLVED)) {
+ // return;
+ // }
+ //
+ // new HgRebaseCommand(project, repository).continueRebase();
+ // }
+ //});
}
};
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
-import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.command.HgPullCommand;
-import org.zmlx.hg4idea.execution.HgCommandResult;
-import org.zmlx.hg4idea.execution.HgCommandResultHandler;
import org.zmlx.hg4idea.ui.HgPullDialog;
import java.util.Collection;
command.setSource(dialog.getSource());
command.setRebase(false);
command.setUpdate(false);
- command.execute(new HgCommandResultHandler() {
- @Override
- public void process(@Nullable HgCommandResult result) {
- new HgCommandResultNotifier(project).process(result, null, null);
- }
- });
+ command.execute();
}
};
}
// limitations under the License.
package org.zmlx.hg4idea.command;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
import org.zmlx.hg4idea.execution.HgCommandResultHandler;
+import org.zmlx.hg4idea.util.HgErrorUtil;
+import org.zmlx.hg4idea.util.HgUtil;
import java.util.LinkedList;
import java.util.List;
private String revision;
private boolean update = true;
private boolean rebase = !update;
+ private static final Logger LOG = Logger.getInstance(HgPullCommand.class);
public HgPullCommand(Project project, @NotNull VirtualFile repo) {
this.project = project;
this.source = source;
}
- public void execute(@Nullable final HgCommandResultHandler resultHandler) {
+ public void execute() {
List<String> arguments = new LinkedList<String>();
if (update) {
arguments.add("--update");
executor.execute(repo, "pull", arguments, new HgCommandResultHandler() {
@Override
public void process(@Nullable HgCommandResult result) {
- project.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(project);
- if (resultHandler != null) {
- resultHandler.process(result);
+ if (HgErrorUtil.isAuthorizationError(result)) {
+ HgUtil.notifyError(project, "Authorization required", "http authorization required for <code>" + source + "</code>");
+ } else if (HgErrorUtil.isAbort(result)) {
+ if (result != null) {
+ LOG.error(new VcsException(result.getRawError()));
+ } else {
+ LOG.error("Error handing result of 'hg pull' execution.");
+ }
+ } else {
+ project.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(project);
}
}
});
import com.intellij.openapi.vfs.VirtualFile;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.*;
import org.zmlx.hg4idea.command.*;
import org.zmlx.hg4idea.execution.HgCommandException;
import org.zmlx.hg4idea.execution.HgCommandResult;
-import org.zmlx.hg4idea.execution.HgCommandResultHandler;
import java.util.ArrayList;
import java.util.List;
throws VcsException {
indicator.setText2(HgVcsMessages.message("hg4idea.progress.pull.with.update"));
HgPullCommand hgPullCommand = new HgPullCommand(project, repo);
- hgPullCommand.setSource(new HgShowConfigCommand(project).getDefaultPath(repo));
+ final String defaultPath = new HgShowConfigCommand(project).getDefaultPath(repo);
+ hgPullCommand.setSource(defaultPath);
hgPullCommand.setUpdate(false);
hgPullCommand.setRebase(false);
- hgPullCommand.execute(new HgCommandResultHandler() {
- @Override
- public void process(@Nullable HgCommandResult result) {
- try {
- ensureSuccess(result);
- }
- catch (VcsException e) {
- LOG.error(e);
- }
- }
- });
+ hgPullCommand.execute();
}
private void update(@NotNull VirtualFile repo, ProgressIndicator indicator, UpdatedFiles updatedFiles, List<VcsException> warnings) throws VcsException {
HgPullCommand pull = new HgPullCommand(myProject, projectRepoVirtualFile);
pull.setSource(new HgShowConfigCommand(myProject).getDefaultPath(projectRepoVirtualFile));
pull.setUpdate(false);
- pull.execute(null);
+ pull.execute();
assertEquals( determineNumberOfIncomingChanges( projectRepo ), 0,
"The update operation should have pulled the incoming changes from the default repository." );