hg: fix i18n warnings

GitOrigin-RevId: 631379069efde9e8c606d1ebcee7728b93945fee
This commit is contained in:
Aleksey Pivovarov
2020-08-18 20:45:37 +00:00
committed by intellij-monorepo-bot
parent 68268743f6
commit 112f6edafe
19 changed files with 81 additions and 54 deletions
@@ -185,7 +185,7 @@ public final class DvcsUtil {
public static final Comparator<Repository> REPOSITORY_COMPARATOR = Comparator.comparing(Repository::getPresentableUrl);
public static void assertFileExists(File file, String message) throws IllegalStateException {
public static void assertFileExists(File file, @NonNls String message) throws IllegalStateException {
if (!file.exists()) {
throw new IllegalStateException(message);
}
@@ -1,3 +1,6 @@
hg4idea.vcs.name=Mercurial
hg4idea.vcs.short.name=Hg
group.hg4idea.file.menu.text=Mercurial
action.hg4idea.tag.title=Tag
action.hg4idea.tag.button=&Tag
@@ -78,6 +81,7 @@ hg4idea.changesets.error.msg=Authentication is required to check incoming/outgoi
hg4idea.changesets.in=In
hg4idea.changesets.out=Out
hg4idea.changesets.checking.progress=Checking Incoming and Outgoing Changes
hg4idea.widget.tooltip.title.status.changesets={0} changesets
hg4idea.switch=Switch to
hg4idea.switch.title=Switch Working Directory
@@ -347,4 +351,12 @@ retry=Retry
revision=&Revision
select.repo=Select repository
specify.name.or.revision=You have to specify appropriate name or revision.
progress.title.enabling.hg=Enabling Mercurial...
progress.title.enabling.hg=Enabling Mercurial...
activity.name.graft=Graft
activity.name.merge=Merge
activity.name.rebase=Rebase
activity.name.update=VCS Update
hg.ref.group.name.branches=Branches
hg.ref.group.name.bookmarks=Bookmarks
@@ -59,6 +59,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import static com.intellij.util.containers.ContainerUtil.exists;
import static com.intellij.util.containers.ContainerUtil.newArrayList;
@@ -70,7 +71,8 @@ public class HgVcs extends AbstractVcs {
private static final Logger LOG = Logger.getInstance(HgVcs.class);
public static final @NonNls String VCS_NAME = "hg4idea";
public static final @Nls String DISPLAY_NAME = "Mercurial";
public static final Supplier<@Nls String> DISPLAY_NAME = HgBundle.messagePointer("hg4idea.vcs.name");
public static final Supplier<@Nls String> SHORT_DISPLAY_NAME = HgBundle.messagePointer("hg4idea.vcs.short.name");
private final static VcsKey ourKey = createKey(VCS_NAME);
private static final int MAX_CONSOLE_OUTPUT_SIZE = 10000;
@@ -120,13 +122,13 @@ public class HgVcs extends AbstractVcs {
@Override
@NotNull
public String getDisplayName() {
return DISPLAY_NAME;
return DISPLAY_NAME.get();
}
@NotNull
@Override
public String getShortName() {
return "Hg";
return SHORT_DISPLAY_NAME.get();
}
@Override
@@ -71,7 +71,7 @@ abstract class HgAbstractFilesAction extends DumbAwareAction {
}
}, null);
helper.showErrors(exceptions, vcs.getName());
helper.showErrors(exceptions, vcs.getDisplayName());
}
@Override
@@ -16,13 +16,16 @@ import com.intellij.notification.NotificationListener;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.xml.util.XmlStringUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.execution.HgCommandResult;
import java.util.Collections;
import java.util.List;
public final class HgCommandResultNotifier {
@@ -44,25 +47,20 @@ public final class HgCommandResultNotifier {
@NlsContexts.NotificationTitle @NotNull String failureTitle,
@NlsContexts.NotificationContent @NotNull String failureDescription,
@Nullable NotificationListener listener) {
List<String> err;
String errorMessage;
if (StringUtil.isEmptyOrSpaces(failureDescription)) {
failureDescription = failureTitle;
List<String> err = result != null ? result.getErrorLines() : Collections.emptyList();
HtmlBuilder sb = new HtmlBuilder();
if (!StringUtil.isEmptyOrSpaces(failureDescription)) {
sb.append(failureDescription);
}
if (result == null) {
errorMessage = failureDescription;
} else {
err = result.getErrorLines();
if (err.isEmpty()) {
LOG.assertTrue(!StringUtil.isEmptyOrSpaces(failureDescription),
"Failure title, failure description and errors log can not be empty at the same time");
errorMessage = failureDescription;
} else if (failureDescription.isEmpty()) {
errorMessage = XmlStringUtil.wrapInHtml(StringUtil.join(err, "<br>"));
} else {
errorMessage = XmlStringUtil.wrapInHtml(failureDescription + "<br>" + StringUtil.join(err, "<br>"));
}
else {
sb.append(failureTitle);
}
if (!err.isEmpty()) {
sb.br();
sb.appendWithSeparators(HtmlChunk.br(), ContainerUtil.map(err, HtmlChunk::text));
}
String errorMessage = sb.wrapWithHtmlBody().toString();
VcsNotifier.getInstance(myProject).notifyError(failureTitle, errorMessage, listener);
}
}
@@ -17,6 +17,7 @@ import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgBundle;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
import org.zmlx.hg4idea.repo.HgRepository;
@@ -50,7 +51,7 @@ public class HgGraftCommand {
List<String> args = new ArrayList<>();
args.add("--log");
args.addAll(params);
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, "Graft")) {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, HgBundle.message("activity.name.graft"))) {
HgCommandResult result =
new HgCommandExecutor(myProject)
.executeInCurrentThread(myRepository.getRoot(), "graft", args);
@@ -62,7 +62,7 @@ public class HgMergeCommand {
arguments.add("--rev");
arguments.add(revision);
}
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, "Merge")) {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, HgBundle.message("activity.name.merge"))) {
HgCommandResult result = commandExecutor.executeInCurrentThread(repo.getRoot(), "merge", arguments);
repo.update();
return result;
@@ -20,6 +20,7 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgBundle;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
import org.zmlx.hg4idea.repo.HgRepository;
@@ -53,7 +54,7 @@ public class HgRebaseCommand {
@Nullable
private HgCommandResult performRebase(@NonNls String @NotNull ... args) {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, "Rebase")) {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, HgBundle.message("activity.name.rebase"))) {
final List<String> list = ContainerUtil.newArrayList(args);
list.add("--config");
list.add("extensions.rebase=");
@@ -14,6 +14,9 @@ package org.zmlx.hg4idea.command;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsNotifier;
@@ -23,11 +26,7 @@ import com.intellij.vcsUtil.VcsFileUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgBundle;
import org.zmlx.hg4idea.HgChange;
import org.zmlx.hg4idea.HgFile;
import org.zmlx.hg4idea.HgFileStatusEnum;
import org.zmlx.hg4idea.HgRevisionNumber;
import org.zmlx.hg4idea.*;
import org.zmlx.hg4idea.execution.HgCommandExecutor;
import org.zmlx.hg4idea.execution.HgCommandResult;
@@ -203,12 +202,13 @@ public final class HgStatusCommand {
if (result == null) {
return changes;
}
List<String> errors = result.getErrorLines();
List<@NlsSafe String> errors = result.getErrorLines();
if (!errors.isEmpty()) {
if (result.getExitValue() != 0 && !myProject.isDisposed()) {
String title = HgBundle.message("action.hg4idea.status.error");
LOG.warn(title + errors.toString());
VcsNotifier.getInstance(myProject).logInfo(title, errors.toString());
String message = new HtmlBuilder().appendWithSeparators(HtmlChunk.br(), ContainerUtil.map(errors, HtmlChunk::text)).toString();
VcsNotifier.getInstance(myProject).logInfo(title, message);
return changes;
}
LOG.debug(errors.toString());
@@ -83,7 +83,7 @@ public class HgUpdateCommand {
final HgPromptCommandExecutor executor = new HgPromptCommandExecutor(project);
executor.setShowOutput(true);
HgCommandResult result;
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, "VCS Update")) {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, HgBundle.message("activity.name.update"))) {
result =
executor.executeInCurrentThread(repo, "update", arguments);
if (!clean && hasUncommittedChangesConflict(result)) {
@@ -38,12 +38,12 @@ public final class HgCommandResult {
}
@NotNull
public List<String> getOutputLines() {
public List<@NlsSafe String> getOutputLines() {
return myProcessOutput.getStdoutLines();
}
@NotNull
public List<String> getErrorLines() {
public List<@NlsSafe String> getErrorLines() {
return myProcessOutput.getStderrLines();
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.LineHandlerHelper;
import com.intellij.vcs.VcsLocaleHelper;
@@ -68,7 +69,7 @@ public final class ShellCommand {
ProcessAdapter outputAdapter = new ProcessAdapter() {
@Override
public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
for (String line : LineHandlerHelper.splitText(event.getText())) {
for (@NlsSafe String line : LineHandlerHelper.splitText(event.getText())) {
if (ProcessOutputTypes.STDOUT == outputType && indicator != null && showTextOnIndicator) {
indicator.setText2(line);
}
@@ -4,6 +4,9 @@ package org.zmlx.hg4idea.log;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
@@ -16,6 +19,7 @@ import com.intellij.openapi.vcs.changes.CurrentContentRevision;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.impl.VcsChangesLazilyParsedDetails;
import com.intellij.vcs.log.impl.VcsFileStatusInfo;
@@ -326,14 +330,15 @@ public final class HgHistoryUtil {
return revisions;
}
List<String> errors = result.getErrorLines();
List<@NlsSafe String> errors = result.getErrorLines();
if (!errors.isEmpty()) {
if (result.getExitValue() != 0) {
if (silent) {
LOG.debug(errors.toString());
}
else {
VcsNotifier.getInstance(project).notifyError(HgBundle.message("hg4idea.error.log.command.execution"), errors.toString());
String message = new HtmlBuilder().appendWithSeparators(HtmlChunk.br(), ContainerUtil.map(errors, HtmlChunk::text)).toString();
VcsNotifier.getInstance(project).notifyError(HgBundle.message("hg4idea.error.log.command.execution"), message);
}
return Collections.emptyList();
}
@@ -15,6 +15,7 @@ import com.intellij.vcs.log.util.VcsLogUtil;
import org.jetbrains.annotations.CalledInAny;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.HgBundle;
import org.zmlx.hg4idea.branch.HgBranchManager;
import org.zmlx.hg4idea.branch.HgBranchType;
import org.zmlx.hg4idea.repo.HgRepository;
@@ -130,8 +131,8 @@ public class HgRefManager implements VcsLogRefManager {
}
}
if (!branches.isEmpty()) result.add(new SimpleRefGroup("Branches", branches, false));
if (!bookmarks.isEmpty()) result.add(new SimpleRefGroup("Bookmarks", bookmarks, false));
if (!branches.isEmpty()) result.add(new SimpleRefGroup(HgBundle.message("hg.ref.group.name.branches"), branches, false));
if (!bookmarks.isEmpty()) result.add(new SimpleRefGroup(HgBundle.message("hg.ref.group.name.bookmarks"), bookmarks, false));
return result;
}
@@ -4,6 +4,7 @@ package org.zmlx.hg4idea.push;
import com.intellij.dvcs.push.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.HgBundle;
@@ -50,8 +51,8 @@ public class HgOutgoingCommitsProvider extends OutgoingCommitsProvider<HgReposit
return new OutgoingResult(Collections.emptyList(), errors);
}
List<String> resultErrors = result.getErrorLines();
if (resultErrors != null && !resultErrors.isEmpty() && result.getExitValue() != 0) {
for (String error : resultErrors) {
if (!resultErrors.isEmpty() && result.getExitValue() != 0) {
for (@NlsSafe String error : resultErrors) {
if (HgErrorUtil.isAbortLine(error)) {
if (HgErrorUtil.isAuthorizationError(error)) {
VcsError authorizationError =
@@ -9,10 +9,11 @@ import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.text.HtmlBuilder;
import com.intellij.openapi.util.text.HtmlChunk;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -117,13 +118,16 @@ public class HgRemoteStatusUpdater implements Disposable {
private final @Nls String string;
private ChangesetFormatter(HgChangesetStatus status, List<HgRevisionNumber> changesets) {
StringBuilder builder = new StringBuilder();
builder.append("<b>").append(status.getStatusName()).append(" changesets</b>:<br>");
HtmlBuilder sb = new HtmlBuilder();
sb.append(HtmlChunk.text(HgBundle.message("hg4idea.widget.tooltip.title.status.changesets", status.getStatusName())).bold())
.append(":").br();
for (HgRevisionNumber revisionNumber : changesets) {
builder.append(revisionNumber.asString()).append(" ").append(revisionNumber.getCommitMessage()).append(" (")
.append(revisionNumber.getAuthor()).append(")<br>");
sb.append(revisionNumber.asString()).append(" ")
.append(revisionNumber.getCommitMessage())
.append(" (").append(revisionNumber.getAuthor()).append(")")
.br();
}
string = XmlStringUtil.wrapInHtml(builder);
string = sb.wrapWithHtmlBody().toString();
}
@Override
@@ -33,7 +33,7 @@ import org.zmlx.hg4idea.util.HgUtil;
public class HgCloneDialog extends CloneDvcsDialog {
public HgCloneDialog(@NotNull Project project) {
super(project, HgVcs.DISPLAY_NAME, HgUtil.DOT_HG);
super(project, HgVcs.DISPLAY_NAME.get(), HgUtil.DOT_HG);
}
@Override
@@ -49,7 +49,7 @@ public class HgConfigurationProjectPanel implements ConfigurableUi<HgProjectConf
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
myExecutablePathSelector = new VcsExecutablePathSelector("Mercurial", this, this::testExecutable);
myExecutablePathSelector = new VcsExecutablePathSelector(HgVcs.DISPLAY_NAME.get(), this, this::testExecutable);
panel.add(myExecutablePathSelector.getMainPanel());
myCheckIncomingOutgoingCbx = new JBCheckBox(HgBundle.message("hg4idea.configuration.check.incoming.outgoing"));
@@ -60,7 +60,7 @@ public class HgConfigurationProjectPanel implements ConfigurableUi<HgProjectConf
mySyncControl = new JBCheckBox(DvcsBundle.getString("sync.setting"));
JPanel mySyncControlPanel = Objects.requireNonNull(UI.PanelFactory.panel(mySyncControl)
.withTooltip(DvcsBundle.message("sync.setting.description", "Mercurial"))
.withTooltip(DvcsBundle.message("sync.setting.description", HgVcs.DISPLAY_NAME.get()))
.createPanel());
if (!project.isDefault()) {
final HgRepositoryManager repositoryManager = ServiceManager.getService(project, HgRepositoryManager.class);
@@ -12,6 +12,7 @@
// limitations under the License.
package org.zmlx.hg4idea.util;
import com.intellij.CommonBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsContexts;
@@ -140,7 +141,7 @@ public final class HgErrorUtil {
}
public static void handleException(@Nullable Project project, @NotNull Exception e) {
handleException(project, "Error", e);
handleException(project, CommonBundle.message("title.error"), e);
}
public static void handleException(@Nullable Project project, @NotNull @NlsContexts.NotificationTitle String title, @NotNull Exception e) {