diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java index 5cc5a26abec8..7b4b0a7b4a81 100644 --- a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java @@ -38,8 +38,4 @@ public class OutgoingResult { public List getCommits() { return myCommits; } - - public boolean hasErrors() { - return !myErrors.isEmpty(); - } } diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java index 8e756d8fe76a..7ae7a33dd6e2 100644 --- a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java @@ -15,9 +15,12 @@ */ package com.intellij.dvcs.push; +import org.jetbrains.annotations.NotNull; + /** * Source to push from. For example, local branch for git or branch/bookmark for mercurial. */ public interface PushSource { + @NotNull String getPresentation(); } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java index 5d6b839e5912..4ee8e504b295 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java @@ -198,14 +198,15 @@ public class PushController implements Disposable { @Override public void onSuccess() { OutgoingResult outgoing = result.get(); - if (outgoing.hasErrors()) { + List errors = outgoing.getErrors(); + if (errors.isEmpty()) { final CommitLoader loader = new CommitLoader() { @Override public void reloadCommits() { loadCommits(model, node, false); } }; - myPushLog.setChildren(node, ContainerUtil.map(outgoing.getErrors(), new Function() { + myPushLog.setChildren(node, ContainerUtil.map(errors, new Function() { @Override public DefaultMutableTreeNode fun(final VcsError error) { VcsLinkedText errorLinkText = new VcsLinkedText(error.getText(), new VcsLinkListener() { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSource.java similarity index 68% rename from plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java rename to plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSource.java index 292e2df7244c..babd49c9b31d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgSource.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSource.java @@ -16,16 +16,23 @@ package org.zmlx.hg4idea.push; import com.intellij.dvcs.push.PushSource; +import org.jetbrains.annotations.NotNull; -public class HgSource implements PushSource { - String mySource; +public class HgPushSource implements PushSource { + @NotNull private String myBranch; - public HgSource(String branch) { - mySource = branch; + public HgPushSource(@NotNull String branch) { + myBranch = branch; } + @NotNull @Override public String getPresentation() { - return mySource; + return myBranch; + } + + @NotNull + public String getBranch() { + return myBranch; // presentation may differ from branch } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java index d2a320297c2f..4bfa134a5e26 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java @@ -80,9 +80,9 @@ public class HgPushSupport extends PushSupport { @NotNull @Override - public HgSource getSource(@NotNull HgRepository repository) { + public HgPushSource getSource(@NotNull HgRepository repository) { String localBranch = HgUtil.getActiveBranchName(repository); - return new HgSource(localBranch); + return new HgPushSource(localBranch); } @Override diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java index e09a09d9d3f1..f019035a373f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPusher.java @@ -57,21 +57,22 @@ public class HgPusher extends Pusher { if (destination == null) { continue; } - HgSource source = (HgSource)hgSpec.getSource(); + HgPushSource source = (HgPushSource)hgSpec.getSource(); Project project = repository.getProject(); final HgPushCommand pushCommand = new HgPushCommand(project, repository.getRoot(), destination.myTarget); pushCommand.setIsNewBranch(true); // set always true, because it just allow mercurial to create a new one if needed pushCommand.setForce(force); - if (source.mySource.equals(hgRepository.getCurrentBookmark())) { + String branchName = source.getBranch(); + if (branchName.equals(hgRepository.getCurrentBookmark())) { if (vcsPushOptionValue == HgVcsPushOptionValue.Current) { - pushCommand.setBookmarkName(source.mySource); + pushCommand.setBookmarkName(branchName); } else { - pushCommand.setRevision(source.mySource); + pushCommand.setRevision(branchName); } } else { - pushCommand.setBranchName(source.mySource); + pushCommand.setBranchName(branchName); } push(project, pushCommand); }