Hg encoding fix for commit

Don't pass "--encoding" to the commit command. Default encoding is fine: it is cp1251/UTF-8 for Win/Unix or HGENCODING if it is set: being set for IDEA it is inherited by the hg process spawned by IDEA.
Together with 7eab3d8f8f it fixes IDEA-67158.

Remove redundant HgEncodingUtil.getDefaultCharsetName
Add javadocs and @NotNulls
This commit is contained in:
Kirill Likhodedov
2011-09-12 18:39:40 +04:00
committed by Kirill Likhodedov
parent 8e6b093342
commit d9f7cdb521
2 changed files with 9 additions and 7 deletions
@@ -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();
@@ -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();
}
}
}