arguments,
+ boolean forceAuthorization) {
- PassReceiver passReceiver = new PassReceiver(myProject, forceAuthorization, myState);
+ PassReceiver passReceiver = new PassReceiver(myProject, forceAuthorization, myIgnoreAuthorizationRequest, myState);
SocketServer passServer = new SocketServer(passReceiver);
try {
int passPort = passServer.start();
@@ -109,11 +115,13 @@ public class HgRemoteCommandExecutor extends HgCommandExecutor {
private final Project myProject;
private HgCommandAuthenticator myAuthenticator;
private boolean myForceAuthorization;
+ private boolean mySilentMode;
@Nullable private ModalityState myState;
- private PassReceiver(Project project, boolean forceAuthorization, @Nullable ModalityState state) {
+ private PassReceiver(Project project, boolean forceAuthorization, boolean silent, @Nullable ModalityState state) {
myProject = project;
myForceAuthorization = forceAuthorization;
+ mySilentMode = silent;
myState = state;
}
@@ -129,7 +137,7 @@ public class HgRemoteCommandExecutor extends HgCommandExecutor {
String path = new String(readDataBlock(dataInputStream));
String proposedLogin = new String(readDataBlock(dataInputStream));
- HgCommandAuthenticator authenticator = new HgCommandAuthenticator(myProject, myForceAuthorization);
+ HgCommandAuthenticator authenticator = new HgCommandAuthenticator(myProject, myForceAuthorization, mySilentMode);
boolean ok = authenticator.promptForAuthentication(myProject, proposedLogin, uri, path, myState);
if (ok) {
myAuthenticator = authenticator;
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java
index dfb576f98ab3..73998ba4ff8e 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgHistoryUtil.java
@@ -94,23 +94,33 @@ public class HgHistoryUtil {
}
/**
- * Get & parse hg log detailed output with commits, their parents and their changes.
+ * Get & parse hg log detailed output with commits, their parents and their changes.
+ * For null destination return log command result
*
* Warning: this is method is efficient by speed, but don't query too much, because the whole log output is retrieved at once,
* and it can occupy too much memory. The estimate is ~600Kb for 1000 commits.
*/
@NotNull
- public static List extends VcsFullCommitDetails> history(@NotNull final Project project, @NotNull final VirtualFile root, int limit,
+ public static List extends VcsFullCommitDetails> history(@NotNull final Project project,
+ @NotNull final VirtualFile root,
+ int limit,
@NotNull List parameters) throws VcsException {
- final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
- if (factory == null) {
- return Collections.emptyList();
- }
HgVcs hgvcs = HgVcs.getInstance(project);
assert hgvcs != null;
final HgVersion version = hgvcs.getVersion();
String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
HgCommandResult result = getLogResult(project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
+ return createFullCommitsFromResult(project, root, result, version);
+ }
+
+ public static List extends VcsFullCommitDetails> createFullCommitsFromResult(@NotNull Project project,
+ @NotNull VirtualFile root,
+ @Nullable HgCommandResult result,
+ @NotNull HgVersion version) {
+ final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
+ if (factory == null) {
+ return Collections.emptyList();
+ }
List hgRevisions =
getCommitRecords(project, result, new HgFileRevisionLogParser(project, getOriginalHgFile(project, root), version));
List vcsFullCommitDetailsList = new ArrayList();
@@ -331,4 +341,8 @@ public class HgHistoryUtil {
}
return branchHeads;
}
+
+ public static String prepareParameter(String paramName, String value) {
+ return "--" + paramName + "=" + value; // no value escaping needed, because the parameter itself will be quoted by GeneralCommandLine
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
index 4adec9dff515..3b989e448b61 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgLogProvider.java
@@ -180,11 +180,11 @@ public class HgLogProvider implements VcsLogProvider {
boolean atLeastOneBranchExists = false;
for (String branchName : filterCollection.getBranchFilter().getBranchNames()) {
if (branchName.equals(TIP_REFERENCE) || branchExists(repository, branchName)) {
- filterParameters.add(prepareParameter("branch", branchName));
+ filterParameters.add(HgHistoryUtil.prepareParameter("branch", branchName));
atLeastOneBranchExists = true;
}
else if (branchName.equals(HEAD_REFERENCE)) {
- filterParameters.add(prepareParameter("branch", "."));
+ filterParameters.add(HgHistoryUtil.prepareParameter("branch", "."));
filterParameters.add("-r");
filterParameters.add("::."); //all ancestors for current revision;
atLeastOneBranchExists = true;
@@ -197,7 +197,7 @@ public class HgLogProvider implements VcsLogProvider {
if (filterCollection.getUserFilter() != null) {
for (String authorName : filterCollection.getUserFilter().getUserNames(root)) {
- filterParameters.add(prepareParameter("user", authorName));
+ filterParameters.add(HgHistoryUtil.prepareParameter("user", authorName));
}
}
@@ -223,7 +223,7 @@ public class HgLogProvider implements VcsLogProvider {
if (filterCollection.getTextFilter() != null) {
String textFilter = filterCollection.getTextFilter().getText();
- filterParameters.add(prepareParameter("keyword", textFilter));
+ filterParameters.add(HgHistoryUtil.prepareParameter("keyword", textFilter));
}
if (filterCollection.getStructureFilter() != null) {
@@ -262,10 +262,6 @@ public class HgLogProvider implements VcsLogProvider {
return HgHistoryUtil.getDescendingHeadsOfBranches(myProject, root, commitHash);
}
- private static String prepareParameter(String paramName, String value) {
- return "--" + paramName + "=" + value; // no value escaping needed, because the parameter itself will be quoted by GeneralCommandLine
- }
-
private static boolean branchExists(@NotNull HgRepository repository, @NotNull String branchName) {
return repository.getBranches().keySet().contains(branchName) ||
HgUtil.getNamesWithoutHashes(repository.getBookmarks()).contains(branchName);
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java
index c60e46c63ced..06b74148156e 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java
@@ -13,6 +13,7 @@
package org.zmlx.hg4idea.provider.commit;
import com.intellij.dvcs.DvcsCommitAdditionalComponent;
+import com.intellij.dvcs.push.ui.VcsPushDialog;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -37,6 +38,7 @@ import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.*;
+import org.zmlx.hg4idea.action.HgActionUtil;
import org.zmlx.hg4idea.command.*;
import org.zmlx.hg4idea.execution.HgCommandException;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
@@ -132,13 +134,12 @@ public class HgCheckinEnvironment implements CheckinEnvironment {
// push if needed
if (myNextCommitIsPushed && exceptions.isEmpty()) {
- final VirtualFile preselectedRepo = repositoriesMap.size() == 1 ? repositoriesMap.keySet().iterator().next() : null;
+ final Set preselectedFiles = repositoriesMap.keySet();
HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(myProject);
- final HgRepository repo = preselectedRepo != null ? repositoryManager.getRepositoryForFile(preselectedRepo) : null;
- final Collection repositories = repositoryManager.getRepositories();
+ final List preselectedRepositories = HgActionUtil.collectRepositoriesFromFiles(repositoryManager, preselectedFiles);
UIUtil.invokeLaterIfNeeded(new Runnable() {
public void run() {
- new HgPusher(myProject).showDialogAndPush(repositories, repo);
+ new VcsPushDialog(myProject, preselectedRepositories).show();
}
});
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgOutgoingCommitsProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgOutgoingCommitsProvider.java
new file mode 100644
index 000000000000..8d24b20ff7c5
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgOutgoingCommitsProvider.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.*;
+import com.intellij.dvcs.push.ui.RepositoryNode;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.command.HgOutgoingCommand;
+import org.zmlx.hg4idea.execution.HgCommandResult;
+import org.zmlx.hg4idea.log.HgBaseLogParser;
+import org.zmlx.hg4idea.log.HgHistoryUtil;
+import org.zmlx.hg4idea.util.HgChangesetUtil;
+import org.zmlx.hg4idea.util.HgErrorUtil;
+import org.zmlx.hg4idea.util.HgVersion;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class HgOutgoingCommitsProvider extends OutgoingCommitsProvider {
+
+
+ private static final Logger LOG = Logger.getInstance(HgOutgoingCommitsProvider.class);
+ private static final String LOGIN_AND_REFRESH_LINK = "Enter Password & Refresh";
+
+ @NotNull
+ @Override
+ public OutgoingResult getOutgoingCommits(@NotNull final Repository repository,
+ @NotNull final PushSpec pushSpec,
+ boolean initial) {
+ final Project project = repository.getProject();
+ HgVcs hgvcs = HgVcs.getInstance(project);
+ assert hgvcs != null;
+ final HgVersion version = hgvcs.getVersion();
+ String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
+ HgOutgoingCommand hgOutgoingCommand = new HgOutgoingCommand(project);
+ PushTarget target = pushSpec.getTarget();
+ if (target != null) {
+ assert target instanceof HgTarget : String.format("Wrong Target for Repository %s", repository.getPresentableUrl());
+ }
+ HgTarget hgTarget = (HgTarget)target;
+ List errors = new ArrayList();
+ if (target == null || StringUtil.isEmptyOrSpaces(hgTarget.myTarget)) {
+ errors.add(new VcsError("Hg push path could not be empty."));
+ return new OutgoingResult(Collections.emptyList(), errors);
+ }
+ HgCommandResult result = hgOutgoingCommand
+ .execute(repository.getRoot(), HgChangesetUtil.makeTemplate(templates), pushSpec.getSource().getPresentation(),
+ hgTarget.myTarget, initial);
+ if (result == null) {
+ errors.add(new VcsError("Couldn't execute hg outgoing command for " + repository));
+ return new OutgoingResult(Collections.emptyList(), errors);
+ }
+ List resultErrors = result.getErrorLines();
+ if (resultErrors != null && !resultErrors.isEmpty() && result.getExitValue() != 0) {
+ for (String error : resultErrors) {
+ if (HgErrorUtil.isAbortLine(error)) {
+ if (HgErrorUtil.isAuthorizationError(error)) {
+ VcsError authorizationError = new VcsError(error, LOGIN_AND_REFRESH_LINK);
+ authorizationError.addClickListener(new TreeNodeLinkListener() {
+ @Override
+ public void onClick(@NotNull DefaultMutableTreeNode source) {
+ TreeNode parent = source.getParent();
+ if (parent instanceof RepositoryNode) {
+ //todo change value to something special, or create force refreshNode method
+ ((RepositoryNode)parent).fireOnChange(((RepositoryNode)parent).getValue());
+ }
+ }
+ }
+ );
+ errors.add(authorizationError);
+ }
+ else {
+ errors.add(new VcsError(error));
+ }
+ }
+ }
+ LOG.warn(resultErrors.toString());
+ }
+ return new OutgoingResult(
+ ContainerUtil.reverse(HgHistoryUtil.createFullCommitsFromResult(project, repository.getRoot(), result, version)), errors);
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java
new file mode 100644
index 000000000000..336f8ff1aa4c
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.VcsPushOptionsPanel;
+import com.intellij.openapi.ui.ComboBox;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionListener;
+
+public class HgPushOptionsPanel extends VcsPushOptionsPanel {
+
+ private final ComboBox myReferenceStrategyCombobox;
+
+ public HgPushOptionsPanel() {
+ setLayout(new BorderLayout());
+ myReferenceStrategyCombobox = new ComboBox();
+ HgVcsPushOptionValue[] values = HgVcsPushOptionValue.values();
+ DefaultComboBoxModel comboModel = new DefaultComboBoxModel(values);
+ myReferenceStrategyCombobox.setModel(comboModel);
+ JLabel referenceStrategyLabel = new JLabel("Export Bookmarks: ");
+ add(referenceStrategyLabel, BorderLayout.WEST);
+ add(myReferenceStrategyCombobox, BorderLayout.CENTER);
+ }
+
+ @Override
+ @NotNull
+ public HgVcsPushOptionValue getValue() {
+ return (HgVcsPushOptionValue)myReferenceStrategyCombobox.getSelectedItem();
+ }
+
+ @Override
+ public void addValueChangeListener(ActionListener listener) {
+ myReferenceStrategyCombobox.addActionListener(listener);
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java
new file mode 100644
index 000000000000..c56d1b8ea5be
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.OutgoingCommitsProvider;
+import com.intellij.dvcs.push.PushSupport;
+import com.intellij.dvcs.push.Pusher;
+import com.intellij.dvcs.push.VcsPushOptionsPanel;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.dvcs.repo.RepositoryManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.repo.HgRepository;
+import org.zmlx.hg4idea.util.HgUtil;
+
+import java.util.Collection;
+
+public class HgPushSupport extends PushSupport {
+ private final Project myProject;
+
+ public HgPushSupport(Project project) {
+ myProject = project;
+ }
+
+ @NotNull
+ @Override
+ public AbstractVcs getVcs() {
+ return HgVcs.getInstance(myProject);
+ }
+
+ @NotNull
+ @Override
+ public Pusher getPusher() {
+ return new HgPusher();
+ }
+
+ @NotNull
+ @Override
+ public OutgoingCommitsProvider getOutgoingCommitsProvider() {
+ return new HgOutgoingCommitsProvider();
+ }
+
+ @Nullable
+ @Override
+ public HgTarget getDefaultTarget(@NotNull Repository repository) {
+ if (!(repository instanceof HgRepository)) return null;
+ String defaultPushPath = ((HgRepository)repository).getRepositoryConfig().getDefaultPushPath();
+ return defaultPushPath == null ? null : new HgTarget(defaultPushPath);
+ }
+
+ @NotNull
+ @Override
+ public Collection getTargetNames(@NotNull Repository repository) {
+ if (repository instanceof HgRepository) {
+ return ContainerUtil.map(((HgRepository)repository).getRepositoryConfig().getPaths(), new Function() {
+ @Override
+ public String fun(String s) {
+ return HgUtil.removePasswordIfNeeded(s);
+ }
+ });
+ }
+ return ContainerUtil.emptyList();
+ }
+
+ @NotNull
+ @Override
+ public HgSource getSource(@NotNull Repository repository) {
+ String localBranch =
+ repository instanceof HgRepository ? HgUtil.getActiveBranchName((HgRepository)repository) : HgRepository.DEFAULT_BRANCH;
+ return new HgSource(localBranch);
+ }
+
+ @Override
+ public HgTarget createTarget(String targetName) {
+ return new HgTarget(targetName);
+ }
+
+ @NotNull
+ @Override
+ public RepositoryManager getRepositoryManager() {
+ return HgUtil.getRepositoryManager(myProject);
+ }
+
+ @Nullable
+ public VcsPushOptionsPanel getVcsPushOptionsPanel() {
+ return new HgPushOptionsPanel();
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java
new file mode 100644
index 000000000000..d9dfbcc5f666
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.PushSpec;
+import com.intellij.dvcs.push.Pusher;
+import com.intellij.dvcs.push.VcsPushOptionValue;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.command.HgPushCommand;
+import org.zmlx.hg4idea.repo.HgRepository;
+
+import java.util.Map;
+
+public class HgPusher extends Pusher {
+
+ @Override
+ public void push(@NotNull Map pushSpecs, @Nullable VcsPushOptionValue vcsPushOptionValue, boolean force) {
+ for (Map.Entry entry : pushSpecs.entrySet()) {
+ Repository repository = entry.getKey();
+ if (repository instanceof HgRepository) {
+ HgRepository hgRepository = (HgRepository)repository;
+ PushSpec hgSpec = entry.getValue();
+ HgTarget destination = (HgTarget)hgSpec.getTarget();
+ if (destination == null) {
+ continue;
+ }
+ HgSource source = (HgSource)hgSpec.getSource();
+ Project project = repository.getProject();
+ final HgPushCommand pushCommand = new HgPushCommand(project, repository.getRoot(), destination.myTarget);
+ pushCommand.setForce(force);
+ if (source.mySource.equals(hgRepository.getCurrentBookmark())) {
+ if (vcsPushOptionValue == HgVcsPushOptionValue.Current) {
+ pushCommand.setBookmarkName(source.mySource);
+ }
+ else {
+ pushCommand.setRevision(source.mySource);
+ }
+ }
+ else {
+ pushCommand.setBranchName(source.mySource);
+ }
+ org.zmlx.hg4idea.HgPusher.push(project, pushCommand);
+ }
+ }
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java
new file mode 100644
index 000000000000..292e2df7244c
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.PushSource;
+
+public class HgSource implements PushSource {
+ String mySource;
+
+ public HgSource(String branch) {
+ mySource = branch;
+ }
+
+ @Override
+ public String getPresentation() {
+ return mySource;
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgTarget.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgTarget.java
new file mode 100644
index 000000000000..8f5aca3838ca
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgTarget.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.PushTarget;
+import org.jetbrains.annotations.NotNull;
+import org.zmlx.hg4idea.util.HgUtil;
+
+public class HgTarget implements PushTarget {
+ @NotNull String myTarget;
+
+ public HgTarget(@NotNull String name) {
+ myTarget = name;
+ }
+
+ @Override
+ @NotNull
+ public String getPresentation() {
+ return HgUtil.removePasswordIfNeeded(myTarget);
+ }
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgVcsPushOptionValue.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgVcsPushOptionValue.java
new file mode 100644
index 000000000000..5b35e7f5e6e0
--- /dev/null
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgVcsPushOptionValue.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.zmlx.hg4idea.push;
+
+import com.intellij.dvcs.push.VcsPushOptionValue;
+
+public enum HgVcsPushOptionValue implements VcsPushOptionValue {
+ None, Current
+}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
index 77c81ee80993..b670fb056c0c 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcs.log.Hash;
@@ -96,6 +97,12 @@ public class HgRepositoryImpl extends RepositoryImpl implements HgRepository {
return myInfo.getState();
}
+ @Nullable
+ @Override
+ public AbstractVcs getVcs() {
+ return HgVcs.getInstance(getProject());
+ }
+
@Override
@NotNull
public String getCurrentBranch() {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
index 1810370588b7..7592f5830ee5 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgErrorUtil.java
@@ -43,7 +43,7 @@ public final class HgErrorUtil {
}
final List errorLines = result.getErrorLines();
for (String line : errorLines) {
- if (!StringUtil.isEmptyOrSpaces(line) && line.trim().startsWith("abort:")) {
+ if (isAbortLine(line)) {
return true;
}
}
@@ -55,8 +55,7 @@ public final class HgErrorUtil {
return false;
}
String line = getLastErrorLine(result);
- return !StringUtil.isEmptyOrSpaces(line) && (line.contains("authorization required") || line.contains("authorization failed")
- );
+ return isAuthorizationError(line);
}
@Nullable
@@ -119,4 +118,12 @@ public final class HgErrorUtil {
Matcher matcher = UNCOMMITTED_PATTERN.matcher(result.getRawError());
return matcher.matches();
}
+
+ public static boolean isAuthorizationError(String line) {
+ return !StringUtil.isEmptyOrSpaces(line) && (line.contains("authorization required") || line.contains("authorization failed"));
+ }
+
+ public static boolean isAbortLine(String line) {
+ return !StringUtil.isEmptyOrSpaces(line) && line.trim().startsWith("abort:");
+ }
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
index ef7f78f38836..3bb14721f0a8 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
@@ -584,11 +584,16 @@ public abstract class HgUtil {
if (state != HgRepository.State.NORMAL) {
branchText += state.toString() + " ";
}
+ return branchText + getActiveBranchName(repository);
+ }
+
+ @NotNull
+ public static String getActiveBranchName(@NotNull HgRepository repository) {
String branchOrBookMarkName = repository.getCurrentBookmark();
if (StringUtil.isEmptyOrSpaces(branchOrBookMarkName)) {
branchOrBookMarkName = repository.getCurrentBranch();
}
- return branchText + branchOrBookMarkName;
+ return branchOrBookMarkName;
}
@NotNull
diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml
index 93aa37c999c8..2b1794d236a3 100644
--- a/resources/src/idea/RichPlatformPlugin.xml
+++ b/resources/src/idea/RichPlatformPlugin.xml
@@ -393,6 +393,9 @@
+
+
+