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;
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);
}
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));
LOG.info("getNumberOfPushedCommits ", e);
return -1;
}
+ } else if (PUSH_NO_CHANGES.matcher(outputLine).matches()) {
+ return 0;
}
}
}
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);
}
}