diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java index 76b4a014f06b..83cf9fb755a3 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java @@ -106,20 +106,23 @@ public class HgPusher { } private static void push(final Project project, HgPushCommand command) { + final VirtualFile repo = command.getRepo(); command.execute(new HgCommandResultHandler() { @Override public void process(@Nullable HgCommandResult result) { - int commitsNum = getNumberOfPushedCommits(result); - String title = null; - String description = null; - if (commitsNum > 0) { - title = "Pushed successfully"; - description = "Pushed " + commitsNum + " " + StringUtil.pluralize("commit", commitsNum) + "."; - } else if (commitsNum == 0) { - title = ""; - description = "Nothing to push"; + if ( result == null ) return; + if ( result.getExitValue() == 0 ){ + int commitsNum = getNumberOfPushedCommits(result); + if (commitsNum > 0) { + String successTitle = "Pushed successfully"; + String successDescription = "Pushed " + commitsNum + " " + StringUtil.pluralize("commit", commitsNum) + " ["+ repo.getPresentableName() +"]"; + new HgCommandResultNotifier(project).process(result, successTitle, successDescription); + } else if (commitsNum == 0) { + new HgCommandResultNotifier(project).process(result, "", "Nothing to push"); + } + } else { + new HgCommandResultNotifier( project ).process(result, null, null, "Push failed", "Failed to push to [" + repo.getPresentableName() + "]" ); } - new HgCommandResultNotifier(project).process(result, title, description); } }); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java index e67c515df57c..b1568f5ce8d2 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java @@ -35,6 +35,12 @@ public final class HgCommandResultNotifier { } public void process(HgCommandResult result, @Nullable String successTitle, @Nullable String successDescription) { + process(result, successTitle, successDescription, null, null ); + } + + public void process( HgCommandResult result, + @Nullable String successTitle, @Nullable String successDescription, + @Nullable String failureTitle, @Nullable String failureDescription ){ List out = result.getOutputLines(); List err = result.getErrorLines(); if (!out.isEmpty()) { @@ -44,9 +50,10 @@ public final class HgCommandResultNotifier { VcsImplUtil.showErrorMessage( myProject, "" + StringUtil.join(err, "
") + "", "Error" ); + } else if ( result.getExitValue() != 0 && failureTitle != null && failureDescription != null ){ + Notifications.Bus.notify(new Notification(HgVcs.NOTIFICATION_GROUP_ID, failureTitle, failureDescription, NotificationType.ERROR), myProject); } else if (successTitle != null && successDescription != null) { Notifications.Bus.notify(new Notification(HgVcs.NOTIFICATION_GROUP_ID, successTitle, successDescription, NotificationType.INFORMATION), myProject); } } - } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java index 768cbb7e70a8..a53bc5db2371 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java @@ -81,4 +81,7 @@ public class HgPushCommand { }); } + public VirtualFile getRepo() { + return myRepo; + } }