diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java index 630c0ee46a66..fcc60365e383 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java @@ -66,8 +66,6 @@ public class HgCommitCommand { for (HgFile hgFile : myFiles) { parameters.add(hgFile.getRelativePath()); } - parameters.add("--encoding"); - parameters.add(HgEncodingUtil.getDefaultCharsetName()); ensureSuccess(new HgCommandExecutor(myProject).executeInCurrentThread(myRoot, "commit", parameters)); final MessageBus messageBus = myProject.getMessageBus(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java index aaf11d01b3f6..cf209ceb3ba3 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/util/HgEncodingUtil.java @@ -16,14 +16,19 @@ public class HgEncodingUtil { private HgEncodingUtil() { } + /** + * Returns the default charset for Mercurial. + * It is cp1251 for Windows, and UTF-8 for Unix-like systems. + * The {@code HGENCODING} environment variable is not considered, because being set for IDEA it is inherited by the hg process + * spawned by IDEA. + * @return cp1251 for windows / UTF-8 for Unix-like systems. + */ + @NotNull public static Charset getDefaultCharset() { return SystemInfo.isWindows ? getCharsetForNameOrDefault(WINDOWS_DEFAULT_CHARSET) : getCharsetForNameOrDefault(UNIX_DEFAULT_CHARSET); } - - public static String getDefaultCharsetName() { - return SystemInfo.isWindows ? WINDOWS_DEFAULT_CHARSET : UNIX_DEFAULT_CHARSET; - } + @NotNull private static Charset getCharsetForNameOrDefault(@NotNull String name) { try { return Charset.forName(name); @@ -32,5 +37,4 @@ public class HgEncodingUtil { return Charset.defaultCharset(); } } - }