diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java index 97c5f9c00ed2..469731ed8628 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java @@ -26,6 +26,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.EventDispatcher; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,11 +52,11 @@ public class CommandExecutor { private final AtomicReference myExitCodeReference; @Nullable private String myMessage; - @Nullable private File myMessageFile; private boolean myIsDestroyed; private boolean myNeedsDestroy; private volatile String myDestroyReason; private volatile boolean myWasCancelled; + @NotNull private final List myTempFiles; @NotNull protected final GeneralCommandLine myCommandLine; @NotNull protected final String myLocale; protected Process myProcess; @@ -81,6 +82,7 @@ public class CommandExecutor { myListeners.addListener(new CommandCancelTracker()); } myLock = new Object(); + myTempFiles = ContainerUtil.newArrayList(); myCommandLine = createCommandLine(); myCommandLine.setExePath(exePath); myCommandLine.setWorkDirectory(command.getWorkingDirectory()); @@ -149,7 +151,7 @@ public class CommandExecutor { } protected void cleanup() { - cleanupMessageFile(); + deleteTempFiles(); } protected void beforeCreateProcess() throws SvnBindException { @@ -167,22 +169,38 @@ public class CommandExecutor { } } + @NotNull + private File ensureCommandFile(@NotNull String prefix, + @NotNull String extension, + @NotNull String data, + @NotNull String parameterName) throws SvnBindException { + File result = createTempFile(prefix, extension); + myTempFiles.add(result); + + try { + FileUtil.writeToFile(result, data); + } + catch (IOException e) { + throw new SvnBindException(e); + } + + myCommandLine.addParameters(parameterName, result.getAbsolutePath()); + + return result; + } + private void ensureMessageFile() throws SvnBindException { if (myMessage != null) { - myMessageFile = createTempFile("commit-message", ".txt"); - try { - FileUtil.writeToFile(myMessageFile, myMessage); - } - catch (IOException e) { - throw new SvnBindException(e); - } - myCommandLine.addParameters("-F", myMessageFile.getAbsolutePath()); + ensureCommandFile("commit-message", ".txt", myMessage, "-F"); + myCommandLine.addParameters("--config-option", "config:miscellany:log-encoding=" + CharsetToolkit.UTF8); } } - private void cleanupMessageFile() { - deleteTempFile(myMessageFile); + private void deleteTempFiles() { + for (File file : myTempFiles) { + deleteTempFile(file); + } } @NotNull