mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
HgPusher now considers the return value of the push command to decide whether an info message or an error message must be shown
This commit is contained in:
committed by
Kirill Likhodedov
parent
bc6f902180
commit
3e5d3fb1b2
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<String> out = result.getOutputLines();
|
||||
List<String> err = result.getErrorLines();
|
||||
if (!out.isEmpty()) {
|
||||
@@ -44,9 +50,10 @@ public final class HgCommandResultNotifier {
|
||||
VcsImplUtil.showErrorMessage(
|
||||
myProject, "<html>" + StringUtil.join(err, "<br>") + "</html>", "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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,4 +81,7 @@ public class HgPushCommand {
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualFile getRepo() {
|
||||
return myRepo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user