[hg] Don't display push error in case of SSL warning, if push is successful. Display...
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Mon, 25 Apr 2011 13:51:26 +0000 (17:51 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Mon, 25 Apr 2011 15:35:32 +0000 (19:35 +0400)
plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommandResultNotifier.java

index 399290077632fb8aa28972708abfdcaed3277f16..776b48d72ddebb60007c07f1e7c9cb5ed9d4be7c 100644 (file)
@@ -39,6 +39,7 @@ public class HgPusher {
 
   private static final Logger LOG = Logger.getInstance(HgPusher.class);
   private static Pattern PUSH_COMMITS_PATTERN = Pattern.compile(".*added (\\d+) changesets.*");
+  private static Pattern PUSH_NO_CHANGES = Pattern.compile(".*no changes found.*");
 
   private final Project myProject;
   private final ProjectLevelVcsManager myVcsManager;
@@ -68,9 +69,12 @@ public class HgPusher {
         int commitsNum = getNumberOfPushedCommits(result);
         String title = null;
         String description = null;
-        if (commitsNum >= 0) {
+        if (commitsNum > 0) {
           title = "Pushed successfully";
           description = "Pushed " + commitsNum + " " + StringUtil.pluralize("commit", commitsNum) + ".";
+        } else if (commitsNum == 0) {
+          title = "";
+          description = "Nothing to push";
         }
         new HgCommandResultNotifier(project).process(result, title, description);
       }
@@ -81,7 +85,8 @@ public class HgPusher {
     if (!HgErrorUtil.isAbort(result)) {
       final List<String> outputLines = result.getOutputLines();
       for (String outputLine : outputLines) {
-        final Matcher matcher = PUSH_COMMITS_PATTERN.matcher(outputLine.trim());
+        outputLine = outputLine.trim();
+        final Matcher matcher = PUSH_COMMITS_PATTERN.matcher(outputLine);
         if (matcher.matches()) {
           try {
             return Integer.parseInt(matcher.group(1));
@@ -90,6 +95,8 @@ public class HgPusher {
             LOG.info("getNumberOfPushedCommits ", e);
             return -1;
           }
+        } else if (PUSH_NO_CHANGES.matcher(outputLine).matches()) {
+          return 0;
         }
       }
     }
index 5eaa0f5bed5440042e2559132c863f743c52fcbf..bc9610dd6fb5e6236619cf0174c4a0be5d4928cc 100644 (file)
@@ -39,11 +39,11 @@ public final class HgCommandResultNotifier {
     if (!out.isEmpty()) {
       VcsUtil.showStatusMessage(myProject, out.get(out.size() - 1));
     }
-    if (!err.isEmpty()) {
+    if (HgErrorUtil.isAbort(result)) {
       VcsUtil.showErrorMessage(
         myProject, "<html>" + StringUtils.join(err, "<br>") + "</html>", "Error"
       );
-    } else if (!HgErrorUtil.isAbort(result) && successTitle != null && successDescription != null) {
+    } else if (successTitle != null && successDescription != null) {
       Notifications.Bus.notify(new Notification(HgVcs.NOTIFICATION_GROUP_ID, successTitle, successDescription, NotificationType.INFORMATION), myProject);
     }
   }